next up previous contents
Next: using ssh-agent Up: Appendix A : Using Previous: Using RSA keys :   Contents

using Secure Copy (scp) to upload/download files

Secure Copy - scp is part of the ssh package and allows you to copy local files to remote ones or vice versa. All transactions are encrypted so nobody can deduce your password.

To use it:

scp thisfile bloggs@remotehost:[path]
e.g
scp thisfile bloggs@remotehost:/users/bloggs/work/.
copies thisfile to /users/bloggs/work/thisfile on remotehost
scp thisfile bloggs@remotehost:work/.
does the same (assuming your remote home directory is in /users/bloggs on remotehost which it is)
scp -r dirname bloggs@remotehost:.
copies the whole local directory tree dirname to dirname under your home directory on remotehost.
scp bloggs@remotehost:/users/bloggs/work/thatfile  thisfile
copies the remote file /users/bloggs/work/thatfile from remotehost to the file thisfile on your local machine.

scp works the same as cp. The first file is what you are copying from and the second what you are copying to. Either file may be a remote directory or file or a local directory or file. Remote files/directories are given using the format:

user@hostname:path
where path can be an absolute path (starting with /). If your local and remote usernames are the same you may omit the user@ part from the remote file name. If the path does not start with / then it assumes a relative path from your home directory - e.g
bloggs@remotehost:/users/bloggs/myfile
is the same as
bloggs@remotehost:myfile
assuming that /users/bloggs is your home directory on remotehost.

Because you can copy whole directory trees you will find it much better than ftp. Also nobody can view your password as it is encrypted.


next up previous contents
Next: using ssh-agent Up: Appendix A : Using Previous: Using RSA keys :   Contents
2004-06-17