home works snippets

Typical SSH Setup

Here is a typical SSH setup that I do when working with servers. I’ll be using Lightsail from AWS to demonstrate the setup.

Connecting to the server via SSH

Once we have a server running in AWS, we would love to do something in that box.

We can use in-browser SSH session which AWS console provides, or we can establish SSH connection ourselves.

Take a look at this snippet for SSH connection on AWS - which shows how to initialize a SSH connection under AWS environment.

Always connected: Mosh

SSH connection is great, but we will find ourselves constantly reconnecting to the server. Whenever we close our Macbook, change WiFi mid-connection, or trying to have fun coding in a cafe where the public WiFi is just terrbly slow, the SSH connection will drop and we will have to re-establish the connection.

To overcome such issue, we can use Mosh. This amazing tool will let us eventually forget how to establish SSH connection. We will stay connected as long as the server is up and running.

Here is a quick Mosh usage snippet that we can refer to establish a Mosh connection.

Multiple terminals

Lightsail Ubuntu box comes with Tmux. Tmux is a great tool that allows a user to manage multiple terminal sessions. Tmux tutorials can be found online if you ask Google.

Check out this Tmux snippet for a quick tutorial of Tmux.

Hope it helped!