Joyent

SFTP from the Command Line

We are covering the command line version of sftp here. Please note that you can do the same thing with a variety of other applications like CuteFTP and Transmit.

To login to your account using sftp is just like logging in with the ssh command. Just type:

 sftp username@servername.textdrive.com

Again you’ll be prompted for your password. Once entered you’ll then be brought to a new prompt that looks like the following:

 sftp>

To get help about all of the commands you can use while logged in to an SFTP connection type ? and press enter.

Some common commands are ls, cd, mkdir rm put and get.

ls allows you to list files on the remote server. Type it in now and you’ll see a list of all files and directories in the current directory you are in. To find out which directory you are currently located in simply type pwd and press enter.

Note that a few commands also have equivalents that operate on the local system. lls lists files on the local computer (ie. yours in most cases) in the current directory. lpwd lists the current working directory on the local computer.

If you wanted to change directories it’s as easy as typing cd directoryname and pressing enter. The same is true on the local machine, lcd directoryname and pressing enter.

To uplaod a file from the local computer, typing put /path/to/filename and pressing enter. Or, if you’re in the local directory of “filename” simply type put filename and it will be uploaded. The same is true of get filename, which will download the file from the remote computer to the local computer in the current working directory.

To delete a remote file, type rm filename and press enter. To remove a directory, rm will not work, instead use rmdir directoryname. Remember, once it’s gone, it’s gone.

Again, exit will exit out of the sftp connection.

Of course, the easiest way to upload and download files is to use your favorite sftp client like Transmit, Interarchy, CuteFTP, etc.

 
all-accelerators/kb/ssh/sftp-command-line.txt · Last modified: 2008/02/17 21:53 by alexbcoles
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki