For all the non-geeks reading this: “Gnome Files” (in this tutorial I will refer to it by its old name, Nautilus) is a file manager in Linux. (A file manager is the program which lets you browse your all your files and folders). “Sftp” is a protocol that makes it possible to remotely access a server that’s running a program called “OpenSSH”.

Recently I discovered that it was possible to use Nautilus in order to access sftp (ssh) servers. Now, this is naturally very handy, because you can just drag and drop the files you want to transfer using your file manager, instead of using an external program such as for instance Filezilla. The following is tested and works fine on my Debian installation, but I’m sure that the basic principle will work under Ubuntu and most distros out there.

Sftp and Nautilus: The basics

Nautilus connect to serverWhat you do is basically to open up Nautilus, and click “connect to server” in the sidebar. (Under “File” in older versions of Nautilus.) Now a dialogue box will pop up, which allows you to connect to the server of your choice. Write sftp:// followed by the address of your server, for instance like this: sftp://ip.to.your.server If you have ssh on another port than the standard port, say 7000, you simply would add :7000 after the ip address of your server. You’ll then be presented with a dialogue button to log in.

Next you’ll have to enter your username and password, and I recommend to let the system remember your login credentials. Now you won’t have to enter password when selecting your server from your bookmarks, although you might might be prompted for a password in order to unlock the keyring of your local system, if this isn’t done automatically on startup.

Old Nautilus with sftp keys connect to server
(Older versions of Nautilus are slightly different, but still pretty much straight forward, first of all you select “ssh” under “type”, then you enter the url of the server, (the prefix of sftp:// isn’t needed) and select the proper port. The default port for sftp is 22. Then you fill in your password and username, and you’re ready to go!)

Bookmarking your server

Nautilus add bookmarkNow, the great thing about this is that once you’ve connected to your server in this way, you can right click on your server under “Network” at the bottom of the left panel in Nautilus, and you’re then given the option to add your server to your Nautilus bookmarks. That’s very convenient, because it means that you don’t have to go through the hassle of writing in your login credentials every time you want to access your server, you can just select it in your bookmark panel, and it will be mounted automatically.

Using Nautilus with keys

All this is fine and dandy, but for security reasons it is highly recommended to use ssh keys instead of passwords on servers that are open on the Internet. Explaining how to set up key authentication is beyond the scope of this tutorial, so I’m assuming that the reader already knows how to do this. (There already are lots of tutorials on the Internet covering this.) The following also assumes that your ssh key is generated without a passphrase.

However, if you want to use Nautilus to connect to a server using ssh keys, you’ll have to set it up slightly differently, compared to when you’re using normal authentication with passwords.

First of all, you need to make sure that your key is loaded, it has to be added to the memory of your computer. On my system I found that I had to manually load the key the before I could connect to the server.

ssh-add /home/user/path-to-your-key/key_name

(You’re key name would in many cases be id_rsa, which commonly is stored in ~/.ssh)

In order to add the key automatically to your memory, you can add the command above to your application autostart list. (In Gnome you can do this from “Startup Application Preferences”, and in Xfce it is found under Settings > Session and Startup > Application Autostart).

Now, Let’s say you run ssh on port 7000, and that your username is “funky”. You’ll then click “Connect to Server”, and under server address you type in something like this:

sftp://funky@ip.to.your.server:7000

Voila! Your server should now be mounted!

A little hint: In never versions of Nautilus, browsing the file system of a server can be difficult unless you have turned the location bar on. (By default your home folder will be mounted). In order to switch it on, simply press “Ctrl-L”.

Using Nautilus with keys on older versions of Nautilus

Old Nautilus sftp
You go to “File”, “Connect to server”, and select “ssh” under “type”. Under “host” you enter your user and the url to your server like this:

yourusername@ip-to-your-server
The “user” and “password” fields, (and this is important) are left *empty*.

That’s all, folks!

Don’t forget to create a bookmark to your server in Nautilus. Accessing your server will then merely be a matter of clicking on the shortcut to your server in Nautilus order to access it. There’ll be no need to enter any password or other credentials. I think you’ll agree with me that using Nautilus in such a manner is a remarkably convenient way to interact with your server. Enjoy!

Advertisements