Remote Development with Atom
**ATOM is now Archived as mentioned here and the links might be broken. I’ll link another guide for different editor in a bit**
I often use a plain text editor for writing code and working on very simple small projects. This works well on local, but working with code files on a server becomes different.
Some time back I figured out Atom had plugins for doing this, and since then Atom became my favorite editor for remote editing. I use it on both windows and mac. The steps below are for windows, but should work for mac as well.
We’ll connect to a remote AWS EC2 instance via ssh using a key pair and then configure the same machine inside Atom for mapping remote folder to a project in Atom. We’ll configure the plugin to user private-key and SFTP, but it it has other options like username-password, FTP, SFTP etc. as well.
Let’s get started with the setup.
Setup Atom
Install Atom from here .
After installing atom, we need to install this plugin. You can either install directly from the web-page after atom is installed or just do it from within atom like this:
Go to File -> Settings
Then click Install and search for remote-ftp
We are interested in the last one remote-ftp
from icetee
which has a good number of installs. Click Install to install it.
If you just search for
remote
you will see many more options. Probably you can try some after this works. For now we’ll use remote-ftp.
We are done with installation. No need to restart Atom. We’ll come back to atom in a bit
The Remote Server
You should be already able to login to remote server via ssh. If you are using a public-private key pair to do so, we are good then. Except for one thing. The plugin didn’t work with simple ssh-rsa key for me when using AWS EC2 instance.
Keep the IP and Username used to login to server handy. If you are using username-password, then next steps won’t be required.
So we can generate another key using this command
ssh-keygen -t ecdsa
This will ask you for a few things, leave everything empty and just hit enter if you don’t understand what they mean, otherwise you can obviously customize.
The command will also print the path for the public and private key-pairs. For example the paths look like this for me
Enter file in which to save the key (C:\Users\leangaurav/.ssh/id_ecdsa):
So the newly generated private key is present in C:\Users\leangaurav/.ssh/id_ecdsa
and the public key in C:\Users\leangaurav/.ssh/id_ecdsa.pub
Now login to your server and add the public key to authorized_keys
file in a new line.
You can test the key is added properly by exiting and logging again using this format
ssh -i <path to private file> <username>@<ip>
For example:
ssh -i C:\Users\leangaurav/.ssh/id_ecdsa ubuntu@35.169.63.136
If it takes you to the server, we are good then. And you can use relative path instead of absolute path for the private key path in the command.
Configuring Atom
Coming back to atom. The plugin stores a config file .ftpconfig
for saving the settings of a remote server. And this file should be present in a project’s root folder. So essentially for multiple servers, one can have multiple projects with different .ftpconfig
file at the root.
Now lets open a new folder or maybe an existing one.
I have opened a folder named workspace
Now go to packages and you’ll find Remote-FTP
there . Click toggle
And you will see another tab Remote
next to the Project
pane in the left, click that
Now hit edit configuration and it will open a empty .ftpconfig
file for you. Now you can either copy the default config from the plugin home page or copy this github gist and paste in the new file.
Now:
- paste the server IP in
host
- username in
user
- remote folder you want mapped to local in
remote
- and the path to the new private key in
privatekey
. On windows private key path needs to have double slash\\
.
It will look like this
Now just hit Connect and Remote
should show the files on server.
Boom !!