Jump to content
Search

The new Ubuntu Wiki is live. Legacy content may be unavailable and page links may have changed. Read the announcement on Discourse.

SSH/Transfer files

From Ubuntu Wiki
< SSH

Tidying

This page has been identified as needing tidying and should be reviewed for clarity, structure, and formatting.

An important function of SSH is allowing secure file transfer using SCP and SFTP.

Secure Copy (scp)

Just as all modern Unix-like systems have an SSH client, they also have SCP and SFTP clients. To copy a file from your computer to another computer with ssh, go to a command-line and type:

scp <file> <username>@<IP address or hostname>:<Destination>

For example, to copy your TPS Reports to Joe's Desktop:

scp "TPS Reports.odw" joe@laptop:Desktop/

This will copy TPS Reports.odw to /home/joe/Desktop, because SCP uses your home folder as the destination unless the destination folder begins with a /.

To copy the pictures from your holiday to your website, you could do:

scp -r /media/disk/summer_pics/ mike@192.168.1.1:"/var/www/Summer 2008/"

The -r (recursive) option copies the whole folder and any sub-folders. You can also copy files the other way:

scp -r catbert@192.168.1.103:/home/catbert/evil_plans/ .

The . refers to the current directory, which becomes the target destination. Alternatively, you could use secret_plans instead of ., and the folder would be renamed.

Secure FTP (sftp)

Finally, if you want to look around the remote machine and copy files interactively, you can use SFTP:

sftp linus@kernel.org

This will start an SFTP session that you can use to interactively move files between computers.

SSHFS

SSHFS[1] allows you to make a remote filesystem available over SSH act as if it was inside a folder on your own system.

For more information, refer to SSHFS.

Notes

  1. ↑ Migration note: the original article included information about SSHFS but it appeared outdated. Future editors can expand this section or create a dedicated and up-to-date SSHFS page.