Linux & Bash: Getting SSHed

In this blog post I'll go through the basics of using SSH.

SSH stands for Secure Shell. It is a "cryptographic network protocol for operating network services securely over an unsecured network." Wikipedia It is modernly used to connect to Linux servers for management and occasionally used by programs for secure connections between machines.

SSH is a service that runs on Linux. Most Linux distributions don't come with SSH installed by default. You can install it in Ubuntu with the following command:

sudo apt intall openssh-server  
sudo systemctl enable ssh # ensures starts on boot  
sudo systemctl start ssh  

Now that SSH is up, we can try SSHing into our Linux system from another machine on the same network. If the machine is a physical one, you need to obtain the local IP address of the machine. If it's virtual, you can either port forward it or obtain the local IP address of the virtual interface.

Windows

The most common SSH client for windows is PuTTY. You can get it by visiting the website and downloading putty.exe.

In the "Host Name" box, enter the IP address. If using port forwarding for a virtual machine running on the same machine, use "localhost". In the "Port" box, you can leave it as 22 or if you configured a different port when port forwarding or installing SSH, use that port.

Click on "Open" and you can log in with your username and password.

macOS, Linux

macOS comes with a built-in command-line SSH client, exactly the same as the one in most Linux systems.

To use the client, open a Terminal and type:

ssh username@hostname  

Hostname is the IP address of the Linux machine, or localhost if using port forwarding. If a non-default port is used, you can specify it as such:

ssh -p 1022 username@hostname