Normally, I use scp to copy files in and out of an EC2 Linux instance. Sometimes, a GUI file browser comes handy to quickly review files. Ubuntu has excellent support for that. One of many reasons why Ubuntu is my development platform of choice. Unfortunately, the steps to connect the Nautilus file browser to EC2 using SSH key is not described very well. Hopefully, this article will help.
Create the Default Key File
First, make sure that you understand the basics of SSH connection to an Amazon EC2 instance. If not, read my previous article on this topic.
At this time, I assume, you already have your private key in the Ubuntu system and are able to do scp and ssh.
Now, copy the private key file in to ~/.ssh folder as the file name id_rsa. For example:
cp demokey.pem ~/.ssh/id_rsa
Basically, id_rsa is the key file that ssh loads by default. We must use this file since Nautilus doesn’t let us choose any other key file.
Launch the Nautilus file browser using the icon as shown above.
From the menubar, select File > Connect to Server.
Enter the hostname or IP address of the EC2 instance. Choose SSH as the type. Enter the user ID (root). Leave the password field blank.
Nautilus will now show the files in the EC2 instance. Now you can copy and paste files between your local machine and the remote EC2 instance. You can also delete or create files in the remote machine.
Caveat: If you store your Amazon key as the default private key, certain SSL connections may fail. For example, I had trouble pushing to GitHub with a “fatal: Authentication failed” message. I had to rename the .ssh folder to be able to authenticate again.