Connecting to a Linux server via SSH
Linux Tutorials

Connecting to a Linux server via SSH

Learn how to connect to a Linux server via SSH in this tutorial. This guide will show you how to establish a secure connection to your server using the Secure Shell (SSH) protocol.

Maciej K
Maciej KOct 19, 2022

In this guide, you’ll learn how to establish an SSH connection to a remote server in less than 60 seconds.

SSH, or secure shell is a type of connection protocol which is encrypted. It is the quickest and easiest way to connect to the command line of, say, your VPS or any remote server, and can be done from all major operating systems.

SSH utilizes a port on a server to listen for connections. Think of it as a letterbox – a letter is sent to a specific letterbox which has the house number on it, and then the tenant can find their mail in that box. In the same way, SSH uses the port (like a house number) to identify all the mail coming towards it – the remote connections.

Getting started

Connecting to a server using SSH is very simple. You’ll usually only need a single command, and if you choose to use an app for it, the details are exactly the same. Here’s what you’ll need:

  • username – the username of the account you want to connect with
  • host name – the host name, usually an IP address, of the target server
  • port – the port of the target server (if it’s not the default)
  • keyfile - the SSH key file, only if an SSH key is to be used instead of a password

Establishing the new SSH connection

Your basic command will look like this:

writer@HostingForFree ~ % ssh [username]@[hostname]

In simple terms, you’re connecting to the account username which is located at the address hostname. This assumes that SSH is running on port 22 which is the default, but this isn’t always the case.

Connecting to alternative ports via SSH

If your port is different, you can specify this in one of two ways:

writer@HostingForFree ~ % ssh [username]@[hostname]:[port] writer@HostingForFree ~ % ssh -p [port] [username]@[hostname]

Login to SSH with SSH key

If you use an SSH key to connect instead of a password, we can adjust for this in the command too:

writer@HostingForFree ~ % ssh -i [keyfile] [username]@[hostname]

Whilst there is a terminal option available for Windows, Mac and Linux, there are also GUI options available. The most popular SSH client is currently PuTTY. All SSH clients, however, will require the same details to log in.


Good job – you’re now connected to the server in record time!

Next article

How to setup an Nginx reverse proxy (Ubuntu)


Get the most talked about articles directly in your inbox

Every week we share the most relevant news in tech, culture and entertainment.

Your privacy is important to us. We promise to not send you spam!