As opposed to SCP, which only allows for single-command transfers, SFTP provides the user with a simple interactive shell for transferring files between your machine and another computer (most likely a server). In addition to providing support for uploading and downloading files, the SFTP shell allows for limited navigation through and manipulation of the local and remote file systems.
Start SFTP by typing sftp username@server_name
at the prompt, filling in the appropriate values for your username and the server's name. The commands that you'll most likely need are listed in Table 4.1, “SSH file transfer (SFTP) commands”.
Note | |
---|---|
SFTP commands look a lot like those discussed in Section 3.2, “Navigating the file system” and Section 3.3, “Manipulating the file system”, but commands to be run on the local machine (the one in front of you) have an |
As far as I can tell, command history and command completion (discussed in Section 3.1, “Features of the shell”) are not available in SFTP. In addition, you cannot transfer entire directories through SFTP; you must compress them first into a tarball[36] and then transfer the tarball.
Example 4.1. Using SSH file transfer (SFTP)
sftp jg18@grid.cec.wustl.edu
[Note that not even asterisks will be displayed on the screen as you type your password.]
You'll then have a prompt like sftp>
at which you can type commands.
Table 4.1. SSH file transfer (SFTP) commands
Category | Command | Action |
---|---|---|
Basic SFTP Commands | --- | |
~ | help or ? | View list of SFTP commands |
~ | exit or quit | Exit SFTP |
Working with File Systems | --- | |
~ |
| Change directory on remote (local) machine |
~ |
| List remote (local) directory contents |
~ |
| Create remote (local) directory |
~ |
| Print name of working remote (local) directory |
~ |
| Rename remote file or directory |
~ |
lrm ) | Remove remote file |
~ |
lrmdir ) | Remove remote empty directory |
Downloading and Uploading | --- | |
~ |
| Download from remote_path to working local directory [to local_path instead] |
~ |
| Upload from local_path to working remote directory [to remote_path instead] |
Other Commands | --- | |
~ |
| Execute some_command on local machine |