Remote server for programmer

Anton Krinitsyn
5 min readMay 21, 2020

Before talking about remote servers let’s see the alternative to really understand the purpose behind using this or that solution.

Docker

Why not use Docker if you need a clean and reproducible environment for testing & other purposes?

With Docker a simple command

docker run --detach --name=remote-ubuntu ubuntu:16.04 tail --follow

will create a container running Ubuntu.

For the most use cases this container is indistinguishable from a remote server.

Run

docker exec --interactive --tty remote-ubuntu /bin/bash

to start ssh-like session and proceed to whatever tasks and tests you would do on a fully fledged remote server.

Additionally a simple Dockerfile

FROM ubuntu:16.04RUN apt update
RUN apt -y install build-essential git

makes is super easy to create reproducible environments.

So, maybe Docker along is enough?

Docker is definitely a good introduction to working with remote servers because you may run the same OS the server would. If you get used to Docker, there won’t be any problem later on switching to a server.

Docker has tons of other use cases. Development, deployment, running apps and more.

I strongly recommend learning Docker. Then take a look at where Docker abstraction is used: Docker Compose, Docker Swarm, Docker Machine, Kubernates. All of them rely on Docker.

On the other hand Docker doesn’t abstract you from the hardware. Give me the simplest thing that has a keyboard and the internet and I won’t feel any different working on it because I would run everything not on local Docker but on the remote server.

Well, I did not try switching fully to remote servers although I mentally ready for that.

And Docker will be one of the first dependencies I’m going to install on my server because there are no problems in using them both.

Remote server

I can’t say how many times I’ve ssh-ed into remote servers for the last several years. Probably thousands of times.

Although I do not have any limitations in my own hardware. Then what are the reasons I am using ssh sessions?

I feel like remote servers give another level of abstraction similar to what Docker gives to a plain local computer.

There are many situations when I need some kind of DB or other 3-rd party service/solution. I prefer to use a remote server with Docker to run services, other than a local environment or container on the local machine. This way I am sure that my services are there waiting no matter what. Either I am on the other computer or someone else uses it when I am absent.

In other words, less thoughts put into configuring dependencies.

Another obvious reason is that you could run applications & share it with others and it will be available all the time for the same reason: the server will run 24/7 for you.

I won’t even mention here that you can easily automate various tasks.

With a remote server you have a great flexibility in terms of your working environment.

There is a mental part to it also. Controlling a remote server on its own is a very interesting idea. You are in control of something that’s far away from you. That’s cool.

Acquire Server on Cloud

Here is an example of how to get a server from Cloud Providers. We are choosing from DigitalOcean, AWS, GCP. Each of them has some kind of free trial. Usually one year of free trial.

Make a Math and you might end up with at least 3 years of free servers from a single credit card.

Even though Cloud Providers try to earn some money, you should not be scared of creating an account and trying their products for free. It will give you the same experience as if you have your own server. Then you will be able to apply skills to any situation. Either it’s your custom local server, or anything else.

I have been using AWS for the most parts. And DigitalOcean on rare occasions, but never GCP. For that reason, let’s move on with GCP option. Although all of them should be similar.

I logged in to GCP console with a newly created gmail.

Then clicked on Activate free trial button at the top and pass card info.

Immediately, a free trial was enabled.

Next step is to create a server. It is also called “VM instance” on GCP. Go to “Compute engine”, “VM Instances” option.

Clicked Create. This is how my config looks like. The cost is 15$ per month. 300$ were given me as per free trial.

I choose Ubuntu instead of default Debian and 20gb disk instead of 10gb.

In security tab I disabled everything because I did not need extra security for this simple example. I also skipped Public Key form for ssh connection. Will do it later.

That is it. Scroll down and click Create. In seconds the instance is up and ready.

Now, we need to establish ssh connection from local machine. Its achieved by adding our local ssh public key to the remote server.

If you do not know what SSH public key stands for check this article.

With GCP it’s a bit different from other providers in how you add public keys to the instance. GCP will override ~/.ssh/authorized_keys file from time to time, so you need to set public key via the browser.

I went to Metadata menu option in the GCP Console and opened SSH Keys section, then clicked Edit button. Copy-paste my local ~/.ssh/id_rsa.pub in and change the user at the end of the key to the one that exists in the remote server.

Then, I rebooted the instance and was able to login from the local terminal.

5 minutes were spent on acquiring this server.

--

--