Set Up An SFTP Server On Ubuntu 12.10 Quantal Quetzal

SFTP (SSH File Transfer Protocol) is basically the File Transfer Protocol run over an SSH connection. Since it uses SSH’s encryption, it’s much more secure than traditional FTP. As an added bonus, there’s no need to set up a separate SFTP server – the OpenSSH Server package includes a built in SFTP server, which is also governed by the /etc/ssh/sshd_config file. Like with an FTP server, you need an SFTP client – but Ubuntu (and most Linux distributions) include one by default.

To create an SFTP server on your Ubuntu 12.10 Quantal Quetzal machine, first install the OpenSSH server and configure it following these directions here. 

Once your new SFTP server is configured, you can access the server using the SFTP client from the command line by simply typing:

sftp

However, it’s far easier to use if you know the IP address of the SSH server you want to access. Let’s say you want to access a SSH server with an IP address of 192.168.1.100. To do so, you would append the IP address to the sftp client command:

sftp 192.168.1.100

The SSH client will then ask for your username. (Note that this will be your username and password on the SSH server, not the computer with the SFTP client.) Type it and hit enter. The client will ask for your password, which you should then enter. Once you do, you’ll be taken to the SFTP prompt, which looks like this:

sftp>

You can also specify a different username as part of the sftp command. If, for instance, you wanted to use an account called camalas to connect to the SSH server at 192.168.1.100, the command would look like this:

sftp camalas@192.168.1.100

If you set up the SSH server to listen on a different port than the default of port 22, you’ll need to tell the SFTP client to use a different port with the “-P” switch. Note that this is different than the SSH client, which uses the “-p” switch – remember that the Linux command line is case-sensitive. To make the SFTP client use the 5589 port, the command should look like this:

sftp –P 5589 192.168.1.100

Once at the sftp  prompt, you can use some of the common terminal commands. To see a listing of the remote directory, you can use the ls command:

ls

This will display the contents of the remote directory.

To find which remote directory you’re actually in, you can use the pwd command:

pwd

This command stands for “print working directory”, and will display the current working directory.

To download files from the SSH server, you will need to use the get command. For instance, to retrieve a file named “report.doc” from the current working directory:

get report.doc

This will download the file to your local home directory.

To upload files to the SSH server, you’ll need to use the put command. To put a file named “data.doc” on the remote server:

put data.doc

This will upload the file to the remote directory on the SSH server.

-JM

ADDITIONAL READING:

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide.

This entry was posted in Ubuntu 12.10. Bookmark the permalink.

Comments are closed.