个人工具

UbuntuHelp:SSH/TransferFiles

来自Ubuntu中文

Wikibot讨论 | 贡献2009年11月17日 (二) 20:41的版本 (创建新页面为 '{{From|https://help.ubuntu.com/community/SSH/TransferFiles}} {{Languages|UbuntuHelp:SSH/TransferFiles}} Parent page: [[UbuntuHelp:InternetAndNetworking| Internet and Networking]...')

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索

Parent page: Internet and Networking >> SSH Another important function of SSH is allowing secure file transfer using SCP and SFTP.

IconsPage?action=AttachFile&do=get&target=IconWarning3.png Limitation: You can't move files between two remote computers. Either the source or destination must be a local file. However, if you log in to a remote machine with ssh, you can copy files between two remote machines on that machine's command-line.

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" [email protected]: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/ [email protected]:"/var/www/Summer 2008/"

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

scp -r [email protected]:/home/catbert/evil_plans/ .

The '.' means to copy the file to the current directory. 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 [email protected]

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

SSHFS

SSHFS is a recent addition to Linux that allows you to make a remote filesystem available over SSH act as if it was inside a folder on your own system. See SSHFS for details.

GNOME

Click Places -> Connect to Server. Select SSH for Service Type, write the name or IP address of the computer you're connecting to in Server, the user you'd like to connect as in User Name, and a name for the connection if you wish. Files can be copied by dragging and dropping between this window and other windows.

KDE

Open Konqueror, and in the address bar type:

fish://[email protected]_address

Files can be copied by dragging and dropping them between this window or tab and to other windows or tabs.

Using other programs

!SecPanel and PuTTY also have file transfer utilities, although they're generally not as easy to use as the ones discussed above.