Using sftp to Copy Many Files Between Machines

sftp is a mix between ftp and scp. Connecting to the server uses the same syntax as scpyou can just specify an IP address to connect using your current username, or you can specify a username using [email protected] You can optionally add a colon and a directory, as with scp. After you are connected, the commands are the same as ftp: cd, put, mput, get, quit, and so on.

In one of the scp examples, we copied a remote file locally. You can do the same thing with sftp with the following conversation:

[[email protected] ~]$ sftp Connecting to [email protected]'s password: sftp> get remote.txt

Fetching /home/paul/remote.txt to remote.txt /home/paul/remote.txt 100% 23 0.0KB/s 00:00

sftp> quit [email protected] ~]$

Although FTP remains prominent because of the number of systems that do not have support for SSH (Windows, specifically), SFTP is gaining in popularity. Apart from the fact that it secures all communications between client and server, SFTP is popular because the initial connection between the client and server is made over port 22 through the sshd daemon. Someone using SFTP connects to the standard sshd daemon, verifies himself, and then is handed over to the SFTP server. The advantage to this is that it reduces the attack vectors because the SFTP server cannot be contacted directly and so cannot be attacked as long as the sshd daemon is secure.

Was this article helpful?

0 0

Post a comment