SCP is creating subdirectory... but I just want it to copy directly - scp

I'm trying to use scp to copy recursively from a local directory to a remote directory.... I have created the folders on the remote side:
Remote Location (already created):
/usr/local/www/foosite
I am running scp from the local machine in directory:
/usr/local/web/www/foosite
But it's copying the "foosite" directory as a subdirectory... I just want the contents of the folder, not the folder itself...
Here is the command I'm using:
scp -r /usr/local/web/www/foosite scpuser#216.99.999.99:/usr/local/www/foosite

The problem is that if you don't use the asterisk (*) in the local part of the call, scp will create a new top level directory in the remote server. It should look like this:
scp -r /usr/local/web/www/foosite/* scpuser#216.99.999.99:/usr/local/www/foosite
This says "Copy the CONTENTS" (but not the directory itself) to the remote location.
Hope this helps... Took me an hour or so to figure this out!!!

Old question, but I think there is a better answer. The trick is to leave the foosite directory off of the destination:
scp -r /usr/local/web/www/foosite scpuser#216.99.999.99:/usr/local/www
This will create the foosite directory on the destination if it does not exist, but will just copy files into foosite if the directory already exists. Basically the -r option will copy the last directory in the path and anything under it. If that last directory already exists on the destination, it just doesn't do the mkdir.

Related

Copy files from remote to local

I tried to copy the file from remote to my local directory but I am getting an error No such file or directory.
Below is the command I used to copy
scp username#remoteserver.xxx:/path to the file/filename /path to the local directory/
All the paths I copied using pwd.
Do you get "No such file or directory" for the
/path to the file/filename
or the
/path to the local directory/
part? If it's the first, then you might have an issue with the path itself. If it's for the second then specifying localuser#localmachine:/path to the local directory/ might fix it. If you're on the same LAN, you could also try localuser#localmachineip:/path to the local directory/

sshfs: will a mount overwrite existing files? Can I tell it to exclude a certain subfolder?

I'm running Ubuntu and have a remote CentOS system which stores (and has access to) various files and network locations. I have SSH access to the CentOS machine and want to be able to work locally on Ubuntu.
I'm trying to mirror a remote directory structure. The remote directory is structured:
/my_data/user/*
And I want to replicate this structure locally (a lot of scripts rely on absolute paths).
However, for reasons of speed, I want a certain subfolder, for example:
/my_data/user/sourcelibs/
To be stored locally on disk. I know the sourcelibs subfolder doesn't change much (but the rest might). So I can comfortably rsync it:
mkdir -p /my_data/user/sourcelibs/
rsync -r remote_user#remote_host:/my_data/user/sourcelibs/ /my_data/user/sourcelibs/
My question is, if I use sshfs to mount /my_data/user:
sudo sshfs -o allow_other,default_permissions, remote_user#remote_host:/my_data/user /my_data/user
Will it overwrite my existing files? Is there a way to have sshfs mount but exclude certain subfolders?
Yes, sshfs will overwrite existing files. I have almost the same use case and just tested this myself. BTW, you'll need to add -o nonempty to your sshfs command since the destination dir /my_data/user already exists.
What I found to work is make a copy of the remote directory excluding the large sub dirs. IDK if keeping 2 copies in sync on the remote machine is feasible for your use case? But if you'll mostly be updating on your local machine and rarely making changes remotely, that could work.

How to show root folders in file tree in cloud9 local ssh install

I've installed cloud9 locally on my remote sever following instructions from Cloud9's "sdkcore" repository on github.
I was able to activate it correctly.
However, once started, the files tree only shows Cloud9 folders, but if you want to edit a file contained in a /var/www/examplefolder directory, I cannot.
I could only modify through the ssh terminal, but I would like to be able to edit the files using the most convenient sublime editor.
How can i fix it?
Thanks.
update:
I resolved creating a link with the command :
sudo ln -s /path/from/folder/you/need /path/to/c9/workspace
in that way you will see your files in c9 workspace folder in the file tree bar;
or
sudo ln -s /path/from/folder/you/need /home/yourusername/
in that way you will see your files in favourites folder in the file tree bar.
If you want to do this, you'll need to create the SSH workspace with the workspace root as / . Alternately, you can open files in the IDE by using the c9 {filename} command.

Kompozer Can't "Publish" web page to my Raspberry Pi Server

I'm not sure how to set the publication settings...
... My RPi is at 192.168.2.126, and is running Apache and ftp.
... The site is to be located in the folder /var/www/GarageDoor on the RPi
... The site is accessed as http://192.168.2.126/GarageDoor/GarageDoors.html
I'm also concerned because my ftp client can't move the file(s) associated with this site directly to /var/www/GarageDoor either. I end up transferring them to my /usr folder, then copying the files manually to the /var/www... folder.
Seems like you need "sudo" permission to copy a file to this folder. I can't figure out how to give either Kompozer or my ftp client such permission. (I'm using bitvise sftp client)
Any ideas would be appreciated.
This sounds a lot like a permissions error. Enter the following into the raspberry pi command line:
sudo chmod 777 /var/www/GarageDoor/GarageDoors.html
Because that would make the file readable by anyone. If that doesn't work, try the +x option to make the file executable.
sudo chmod +x -R /var/www/GarageDoor
Note on the second command: This will make all files in /GarageDoor have executable permissions. (-R is for recursive)

SCP copies files successfully, but files not visible in local computer

I SCP ed to copy files successfully, i.e. the transfer shows it's successful, but I don't see anything in my local folders.
The command:
scp name1#server1.edu:/file/*.* ~/Desktop/
I am running Debian, if that might be of some help.
Check the SFTP home path.Your successfully transferred files are copied by default to this path.Hope this will help you !