Other Languages: Français?
command.
Say you want to copy a file called 'dumb' from the current directory of the local machine to your home directory on a remote machine called www.foobar.com. Your account name on the remote machine is 'bilbo'. The command would be:
To copy it back:
'scp' calls SSH to do the login, then it copies the file and then calls SSH again to close the connection.
If your '~~/.ssh/config' already contains a configuration for your account on www.foobar.com like
Host *fbc
~HostName www.foobar.com
User bilbo
~ForwardAgent yes
then you can replace 'bilbo@www.foobar.com' with 'fbc':
'scp' assumes your home directory on the remote machine to be your current working directory, so if you are using relative paths for the remote machine, they have to be relative to the location of your home directory on that machine.
Using the switch for 'scp', you can also copy directories recursively. 'scp' also allows you to copy files between remote machines.
Now you might be tempted to try something like this: you open an SSH connection to www.foobar.com. Once you are logged in, you type to copy the local file 'dumb' to the remote server you are currently logged in. Most likely you will get a message like
What has happened is that you executed the remote version of 'scp', and it tried to connect to an SSH server running on your machine … So remember to run 'scp' always from a local terminal, unless your machine also runs an SSH server.
section index
command. Since version 2.0.7, the popular graphical FTP client gftp supports sftp-transfers, which makes up for sftp's somewhat limited feature set. In Konqueror you simply type into the upper URL line field to use it.
If the remote server doesn't have the sftp server, 'sftpserv', running, just copy the 'sftpserv' executable to your remote home directory (or a directory you have access to and which is included in your remote $PATH). 'sftp' will activate this server automatically upon connect. You'll need no extra permissions on the remote server.
There is a big problem with the usage of sftp on a command line. It is not able to copy also folders inside of other folders recursively. Use scp instead of it.
section index
. I'm using it myself for MUO ;-).
One of the advantages of 'rsync' is, that it only transfers the differences between two given sets of files. A whole file is only transferred if it is missing at the target location. Furthermore it offers a very efficient method for compressing data and thus makes transfers even faster.
You'll find 'rsync' on your Mandrake CD. section index
The basic idea is to forward a port, fork SSH into the background and occupying it with a senseless command to keep the channel open:
Now start an FTP client, and point it at the forwarded port:
Whereas commands like are OK, commands like or either result in a hanging process or mysterious error messages or both.
There are several programs which try to get around this problem: ftpsshd and hsftp. But all of them are either not working correctly or are too inconvenient to use.
Bottom line: For transferring files, better stick with one of the first three methods.
section index
Next Item: Tunneling POP, X, VNC ...
Other Languages: Français?
Getting started with SSH
, ,
Revision / Modified: Sep. 27, 2001
Author: Tom Berger Legal: This page is covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB and Mandrakesoft.
SSH IV
Summary:- Copying Files With 'scp'
- Copying Files With 'sftp'
- Copying Files using 'rsync'
- Copying Files Via Tunneled FTP
Copying Files With 'scp'
SSH gives you access to a set of commands and a shell on a remote machine. By itself, it does not enable you to copy files, it however provides thescp
Say you want to copy a file called 'dumb' from the current directory of the local machine to your home directory on a remote machine called www.foobar.com. Your account name on the remote machine is 'bilbo'. The command would be:
scp dumb bilbo@www.foobar.com:.
scp bilbo@www.foobar.com:dumb .
scp dumb fbc:.
Using the
-r
scp {local machine}:dumb .
ssh: secure connection to {local machine} refused
Copying Files With 'sftp'
If you prefer a more 'ftp-ish' approach, try sftp (part of the sftp RPM). 'sftp' establishes an SSH tunneled FTP connection to a server and allows you to use most of the standard FTP command set. As an added bonus, 'sftp' allows you to run remote programs via theexec
sftp://serverdomain
Copying Files using 'rsync'
'rsync', the immensely useful tool for copying, updating and removing remote and local files, can most easily be used with SSH by adding the option-e ssh
One of the advantages of 'rsync' is, that it only transfers the differences between two given sets of files. A whole file is only transferred if it is missing at the target location. Furthermore it offers a very efficient method for compressing data and thus makes transfers even faster.
You'll find 'rsync' on your Mandrake CD. section index
Copying Files Via Tunneled FTP
If you really insist on using your traditional FTP client, prepare for some fiddling ;-). SSH allows all kinds of protocols to be 'tunneled', FTP too. FTP is a bit of a weird protocol however (e.g. it requires two ports) and results may differ from server to server and from client program to client program. If your FTP client doesn't support connecting to a specified port, you can forget it right away. The magic word is 'port forwarding'. You forward a non-privileged local port (i.e. usually a port > 1000) to a remote server and then connect to the local machine. Sounds complicated? Well, it is. And I can't be of much help here since I haven't got to getting it working either.The basic idea is to forward a port, fork SSH into the background and occupying it with a senseless command to keep the channel open:
ssh {user@remote host} -f -L 1234:{remote host}:21 tail -f /etc/motd
lftp -u {user name} -p 1234 localhost
cd
ls
get
Related Resources:
SSH FAQGetting started with SSH
man scp
man sftp
man rsync
Author: Tom Berger Legal: This page is covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB and Mandrakesoft.
SSH IV
Version 1.7 last modified by Flink on 06/01/2007 at 09:57
Version 1.7 last modified by Flink on 06/01/2007 at 09:57
Document data
- Lost account?
- Join the community, be part of the Club: it's free!
- Get the PWP Download Subscription!


