Hot answers tagged

95

In the past, the way in which scp worked, when called (naively) to copy files between remote systems, was very inconvenient: if you wrote, for instance scp user1@remote1:/home/user1/file1.txt user2@remote2:/home/user2/file1.txt scp would first open an ssh session on remote1, and then it would run scp from there to remote2. For this to work, you would ...


83

From Wikipedia: Compared to the earlier SCP protocol, which allows only file transfers, the SFTP protocol allows for a range of operations on remote files – it is more like a remote file system protocol. An SFTP client's extra capabilities compared to an SCP client include resuming interrupted transfers, directory listings, and remote ...


70

In a nutshell, SCP can only be used for transferring files, and it is non-interactive (i.e., everything has to be specified on the command line). SFTP is more elaborate, and allows interactive commands to do things like creating directories, deleting directories and files (all subject to system permissions, of course), etc.


64

The way the question is asked is pretty confusing, but if you can copy from your local machine to the server, to go the other way just flip the command line order. its scp [from] [to] scp user@homeip:/path/to/file /local/path/


47

Rsync will obviously be faster than scp if the target already contains some of the source files, since rsync only copies the differences. But I suspect your question was about doing a straightforward copy to an empty target. You've passed the -z option to rsync; this turns on compression. If the network bandwidth is the limiting factor (it often is), ...


45

To send a file: cat file | ssh ajw@dogmatix "cat > remote" Or: ssh ajw@dogmatix "cat > remote" < file To receive a file: ssh ajw@dogmatix "cat remote" > copy


43

You can pipe into ssh and run a remote command. In this case, the remote command is cat > big.txt which will copy stdin into the big.txt file. echo "Lots of data" | ssh user@example.com 'cat > big.txt' It's easy and straightforward, as long as you can use ssh to connect to the remote end. You can also use nc (NetCat) to transfer the data. On the ...


37

I know this is a late answer, but I just found out a cool way to do this. It is basically Holger Just's answer, but in a saved config file: You need to put this in your ~/.ssh/config file on local.machine, (creating the file if it does not exist) Host target.machine User targetuser HostName target.machine ProxyCommand ssh proxyuser@...


36

First, you need to copy the file to a place where you have write access without sudo, scp yourfile serverb: Then move the file using sudo ssh serverb sudo mv yourfile /path/to/the/destination If you do not have a writable place, make a temporary dir with write permission for your user. ssh serverb sudo mkdir tempdir && sudo chmod 777 tempdir ...


35

Something like this should work well: tar c some/dir | gzip - | ssh host2 tar xz Maybe also omit gzip and the "z" flag for extraction, since you are on a gigabit network.


33

ProxyCommand Updated to include -W from other answers: A$ scp -oProxyCommand="ssh -W %h:%p B" thefile C:destination The "-W" is a rather recent feature. If B has a very old SSH client installed, use alternatives: A$ scp -oProxyCommand="ssh B socat stdio tcp:%h:%p" thefile C:destination A$ scp -oProxyCommand="ssh B nc %h %p" thefile C:destination Pipes ...


33

You can also use inotifywait from the inotify-tools package. inotifywait -r -m -e close_write --format '%w%f' /tmp | while read MODFILE do echo need to rsync $MODFILE ... done


33

-i identity_file Selects the file from which the identity (private key) for public key authentication is read. This option is directly passed to ssh(1). Use ~/.ssh/id_rsa.


32

Not just the admin. For testing, I just copied /bin from my server to a temporary directory on my laptop. ps on the server shows $ ps 24096 PID TTY STAT TIME COMMAND 24096 ? Ss 0:00 scp -r -f /bin This information is generally accessible to all users.


31

FTPS is FTP using the SSL protocol for encryption. This is different from the SCP/SFTP family of protocols which use SSH as their transport tunnel. You will usually use the same client programs for SCP and SFTP (WinSCP for instance; SFTP is an upgraded version of SCP), whereas you usually use a web browser or web Download manager (like Filezilla) for FTPS. ...


31

A ServerFault question is almost identical to this. Hopefully you checked before posting your question, but yours is a little different so I will answer here. The short answer is that if ANYONE has access and permissions to an endpoint (the system you are scping from or scping to), they can see what happens. If they do not have access to either endpoint, ...


30

Copy the file "foobar.txt" from a remote host to the local host $ scp your_username@remotehost.edu:foobar.txt /some/local/directory Copy the file "foobar.txt" from the local host to a remote host $ scp foobar.txt your_username@remotehost.edu:/some/remote/directory Copy the directory "foo" from the local host to a remote host's directory "bar" $ scp -r ...


30

Escape your wildcard : scp hostA:Descargas/debian-6.0.4-\*


25

One possible cause of this type of behavior is having any message print out during the login process on server. Scp depends on ssh to provide a totally transparent encrypted tunnel between the client and the server. Check all of the login scripts on the server, and also try using a different user. Another method of identifying the source of the error is ...


24

Use tar: tar cvzf - -T list_of_filenames | ssh hostname tar xzf -


24

Originally I recommended http://www.swish-sftp.org/. It adds an 'Other' Swish drive in which each folder is an SFTP connection however this can't be accessed in all applications such us Java based Eclipse IDE or Notepad++. An alternative that works is http://www.eldos.com/sftp-net-drive/ or even runing Apache WebDAV (over SSL) as windows can natively map ...


24

I don't think you can, but you could use rsync? Something like this: rsync -a --exclude=a/c myserver:/a .


22

System Preferences pane → Sharing applet → check the Remote Login checkbox. This will enable SSH, and in turn, SCP.


22

From the help text: "... [-F ssh_config] ..." According to the above, -F expects one argument: path to an OpenSSH configuration file, ~/.ssh/config or similar. But you are giving it a gzipped SQL dump instead. Since plain ssh myalias is already working, you don't even need the -F option here. Just sftp myalias would connect to the server. However, the ...


22

How about using rsync instead with the -z option enabled for compression? rsync -az --progress source_dir/* remote_host:/destination_dir This also has the added benefit that if the file already exists and has not changed on the destination, it will not be transferred.


19

The scp option -3 ought to be what you are looking for. To put it in your example: scp -3 root@firstcomputer:./file root@secondcomputer:./ Note that the -3 option was first introduced in OpenSSH 5.7, which was released early 2011.


17

You can use ssh and tar to work around this: ssh -t host 'sudo -v' ssh -C host 'cd /; sudo tar cf - path/to/file/or/dir' | tar xpsf - --preserve This first updates your sudo timestamp (asking for a password if necessary, which requires a tty (ssh -t)), and then uses sudo to create a tarball remotely and extract it locally. "tar" on RedHat 5 requires the "...


17

If you're copying from a windows machine, you can use WinSCP to copy, and it has an option to set the permissions on the copied files after the upload. If not, I think your only choice is to execute a chmod on the server after the upload, which you could do remotely with an ssh command: scp /path/to/file server:/server/path/to/file ssh server chmod 644 /...


16

You can use SSH tunneling for this. Using tunneling you can forward a TCP port either from your local machine to the remote machine, or from the remote machine to your local machine. I use it frequently to forward e.g. SMTP or IMAP ports from a remote machine behind a firewall to my local machine (and then access the services locally, as if they were ...


16

I'm sure the fact that you have all FIVE MILLION files in a single directory will throw many tools into a tizzy. I'm not surprised that rsync didn't handle this gracefully - it's quite a "unique" situation. If you could figure out a way to structure the files into some sort of directory structure, I'm sure the standard sync tools such as rsync would be ...



Only top voted, non community-wiki answers of a minimum length are eligible