Breadcrumbs 
Learning >> Documentation >> Internet >> SFTP
 
Recent News
We're No 1!
We've reached the top! (Of Google!)
[ more ]
Firefox 3 Download Day
Firefox 3 has been officially released and is looking to set a world record for the most downloaded piece of software in 24hrs.
[ more ]
SSL Renewed
SSL cert has been renewed by the admin team.
[ more ]
SFTP
SFTP

sftp is the replacement for scp and is the secure version of the standard ftp - File Transfer Protocol. It is more efficient and much more versitile than scp when transfering files, which is to be expected since it was designed for file transfers while scp was little more than a hack to deal with the problem until sftp became mainstream.

man page description, of which a more complete version including usage can be found using man sftp.

sftp is an interactive file transfer program, similar to ftp, which performs all operations over an encrypted ssh transport. It may also use many features of ssh, such as public key authentication and compression. sftp connects and logs into the specified host, then enters an interactive command mode.
The second usage format will retrieve files automatically if a non-interactive authentication method is used; otherwise it will do so after successful interactive authentication.

This page will only cover what differences the secure layer usage requires and assumes that if you haven't read the page on ftp you are familiar with ftp in any case. If you want to learn how to use ftp, its recommended that you read the documentation that is devoted to it.

General commands
-o ssh_option : allows options to be passed through to ssh. e.g. -oPort=24
-s subsystem | sftp_server : Specifies the SSH2 subsystem or the path to the sftp server on the remove server.
-C : enables compression using ssh.
-F ssh_config : allows you to specify a different config file to be used by ssh when connecting.
-1 : specifies that version 1 of ssh should be used. Useful when connecting to a machine that only has the older version available.

In general you will use the generic format of this command in connecting to most servers for using sftp and for connecting to the Computer Society servers as well. The generic view is the first one while the second example is the actual command that you would use. Normally when connecting no options are required, so their skipped.

$ sftp [options] [[user@]host[:dir]]
$ sftp username@compsoc.nuigalway.ie

Naturally you should substitute username with whatever is your correct username for the server your connecting to.

The last optional part of the sftp program call is the remote directory to set as the working directory on the remote machine when started. Normally this defaults to your home directory but in cases where you have a script or want to create a series of aliases (see section on bash for more) to use sftp to access machines and locations regularly, this is a useful addition. For example imagine you want to connect to a server to upload a new copy of a website. But the website is located several directories down for example ~/public_html/sample_web/development/latest/html/ Its much easier to create an alias to automatically have sftp go to that location automatically.

$ sftp username@compsoc.nuigalway.ie:~/public_html/sample_web/development/latest/html

Of course this is also useful when using normal ftp and can also be used with scripts when you want to perform non interactive connection and retreivals such as an automated remote retreival (remote backup).

Check out the page on ftp for more about the interactive commands that can be used within ftp and sftp.