• Sales: 1-800-961-2888
  • Support: 1-800-961-4454

Rackspace Cloud Essentials 5 - Secure File Transfer Protocol (SFTP)


An alternative to using vsftpd, Secure FTP (SFTP) is another secure method of transferring files from one server to another.

Contents

//

Installation

SFTP (SSH File Transfer Protocol) is part of the SSH package, and the SSH package should be on your server by default.  You don't need to install anything else to support SFTP.

Configuration

Your SSH server should have SFTP enabled by default, so if you're able to make SSH connections you should be able to use SFTP without additional configuration.

If you want to make sure of that, the pertinent section in the SSH server's config file (usually "/etc/ssh/sshd_config") should look like:

# override default of no subsystems
Subsystem	sftp	/usr/libexec/openssh/sftp-server

So long as that Subsystem entry is there for the sftp server you're good.  If you can't find that line in your sshd_config you can add it to the end of the file and then restart the SSH server to enable sftp.You can learn more about configuring the SSH server in our article on basic Linux server security.

Security

As mentioned, SFTP uses the SSH protocol to connect to your Server.

As such, the connection and all data is encrypted to prevent any eavesdropping of passwords or sensitive data.

SFTP Client

We can start by looking at an SFTP client.

The 'client' is a programme on your local workstation. I won't go into listing all the available SFTP clients but suffice to say that the vast majority of modern FTP clients also support SFTP (keep in mind SFTP does not use the 'typical' FTP protocols and so some older FTP clients may not support SFTP).

You can search for SFTP clients for Windows, OS X, Linux or other Operating Systems.

Due to the vast array of clients available I can't go into how to use each one (they should have plenty of documentation with the software).

However, the preferences/options panel will allow you to enter the SFTP details.

Take a look at this example:

sftp.png

If you have followed the setup articles (see the link above) you will notice the details are the same as those we used to setup SSH.

We have the Server IP, the user named 'fred', and we will be using the standard port 22.

The protocol has been specified as SFTP over SSH2 - this particular client has several options available.

Lastly, you should be able to set the path for the UI. In this case, I want to open the client in my home partition.

Once I have submitted the information, I am connected to the Server:

sftp2.png

Note: In this case I have accessed the Server at the root folder level. As such, you can browse the folders as shown above.

Most clients will allow you to 'double click' on a file and edit it in a local browser.

Permissions

Which brings us nicely to permissions.

Do remember that you are using the same details as the SSH user - as such they won't be able to automatically edit files owned by root.

All that would happen is a nice 'permission denied' error if you tried to open or save any changes to a root owned file.

So what to do about the permissions?

Well, to be honest, there isn't a lot you can do about it. The permissions are there for a good reason and are an integral part of Linux and how it is designed.

Neither do I recommend logging in as root - part of the initial SSH setup entailed disabling root logins.

However, beyond the initial setup, there should be little reason to mess around with files owned by root and any changes in configurations would be done from the command line using the 'sudo' command.

The main reason for using SFTP clients is to ease the transfer of files - most of which will be to your public_html folder which you will have permission to write.

 

Those are just a few of the methods that you can easily use to set up secure file transfers to your Linux Cloud server.  If you are using a Windows Server, you may need still need to use FTP.  The following article shows you how to set up an FTP site in IIS 7.0.  

 



© 2011-2013 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License


See license specifics and DISCLAIMER

9 Comments

This dosn't work for me on a small server, I get
Error: Out of memory!
Error: Could not connect to server
checked the memory on the server - shows 83Mb used 161 Mb free

It sounds to me like the client may be running into problems trying to output text resulting from a command in a bashrc file. Try moving some of the initial login text to the .profile or .login file instead and see if that lets you sftp in, and please let us know if that does the trick.

Hi jered.heeschen

I've one question, whats the SFTP Client you've used in this example?
well still feels it troublesome to find a good 'SFTP Client' running on Linux..FIlezilla doesn't support password-encrypted private keys.. I ended up using command line for uploading my files, any suggestions will be appreciated? I'm using Debian with Gnome 2

many thx for this tutorial
Yan

I can't say for certain which client the author used, but it looks like it's probably Krusader, a KDE SFTP client. Fortunately you can run it under Gnome if you install the right libraries (which apt-get/aptitude will do for you if you go to install the "krusader" package). Another Linux client I've heard good things about, but haven't used myself, is SecPanel.

thx jered for ur suggestion..I installed SecPanel (not comfortable with it).. the others I tried are Krusader, gnome-commander..konqueror, Dolphin..and fireftp.. none of them worked as expected.. (no one supports password-encrypted private keys) seems I should be happy using command line ;).. really strange that windows has a good sftp (WINSCP).. but linux lacks..

Have you looked at the "ssh-agent" command? There should be a few good tutorials about it out there (I'll add it to my list of things to do for this site). It should work in the background for most programs and allow you to authenticate your key so those other programs can use it.

many thanks.. 'ssh-agent' did it.. and it works.. I'm able to connect using any ssh client now.. you saved me a lot of time, really your help greatly appreciated.. :)

Example: Under 'Configuration' -

1st sentence: "There is also nothing to configure."
2nd sentence: "Once you have setup your user(s) and configured SSH for your needs, SFTP uses the same usernames and ports."

Being 100% new to Rackspace Cloud Servers, this doesn't help.

Thanks for pointing that one out, KS. I agree, it's a bit confusing. I'll reword that section. The basic meaning of that is supposed to be that if you have SSH connections to the server working, then SFTP will work without additional changes to the server being necessary.

Add new comment