Securely Transfer Files Between Machines


sftp

In the same way that ssh is a far better choice than telnet, SFTP is far better than FTP. Like telnet, FTP sends your name and password, as well as all the data being transferred, in the clear so that anyone sniffing packets can listen in. SFTP, on the other hand, uses ssh to encrypt everything: username, passwords, and traffic. Other than the fact it's about a million times more secure, it's remarkably similar to FTP in its commands, which should make it easy to learn and use.

If you can access a machine via ssh, you can also SFTP to it. To use the sftp command from pound (192.168.0.15; username ezra) to eliot (192.168.0.25; username tom), just use this command:

$ sftp tom@192.168.0.25 Connecting to 192.168.0.25... tom@192.168.0.25's password: sftp> 


If you've read the previous section, "Securely Log In to Another Machine Without a Password," you might be wondering why you were prompted for a password. You're correct: The preceding example was taken before a connection that didn't require a password was set. After you've done that, you would instead see a login that looks like this:

$ sftp tom@192.168.0.25 Connecting to 192.168.0.25... sftp> 


After you're logged in via sftp, the commands you can run are pretty standard. Table 15.1 lists some of the more common commands; for the full list, look at man sftp.

Table 15.1. Useful SFTP Commands

Command

Meaning

cd

Change directory

exit

Close the connection to the remote SSH server

get

Copy the specified file to the local machine

help

Get help on commands

lcd

Change the directory on the local machine

lls

List files on the local machine

ls

List files in the working directory on the remote SSH server

put

Copy the specified file to the remote SSH server

rm

Remove the specified file from the remote SSH server




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net