SSH on Linux VPS (Virtual Private Servers) Servers, It provides a secure way to give remote access and control. In this post, we will show you how to log into a Linux VPS with SSH using either the method of using a password or a public key.

Additionally, we will discuss popular SSH clients such as PuTTY, Termius, and Bitvise and examine cloud provider-specific methods for SSH key generation, including those from AWS, Google Cloud, and Azure. Whether you are new to Linux VPS management or looking to refine your SSH skills, this guide aims to equip you with the knowledge you need.
SSH is a secure protocol to connect with another machine, which is usually a VPS(Linux Machine). Unlike standard remote access protocols, SSH encrypts the connection, so unauthorized users can’t intercept your data and commands. For server management, SSH commands are invaluable to system administrators as well as to those who develop and require secure communications.
Before you begin, ensure you have the following:
Password-based login is the simplest way to access your VPS via SSH. Follow these steps:
In your terminal or SSH client, type the following command:
ssh username@server-ip

Replace username with your server username (often root) and server-ip with your VPS’s public IP address.
Example:
ssh [email protected]
Type your password when asked. When you are successful, you will gain access to the VPS command line. Once you have logged in, you are able to start getting commands down and control your server.
A better way to log in is the SSH key. Here’s how to set it up:
Use the following command on Linux or macOS to generate an SSH key pair:
bash
ssh-keygen -t rsa

Use this command to generate a public and private key pair, typically stored in the ~/.ssh directory. Windows users can use PuTTYgen to generate their keys.
When prompted, you can accept the default file location by pressing Enter. You may also choose to add a passphrase for an extra layer of security.
To transfer your public key to the VPS, use the following command:
bash
ssh-copy-id username@server-ip
This command appends your public key to the authorized_keys file on the server, allowing for passwordless logins.
Example:
ssh-copy-id [email protected]
Now that you have set up key-based authentication, you can log into your VPS using your private key:
ssh -i /path/to/private_key username@server-ip

Example:
ssh -i ~/.ssh/id_rsa [email protected]

Once you have set up SSH keys, you will not need to enter a password, enhancing both convenience and security.
To connect your Linux VPS while using Windows, you will need an SSH client. Below are some popular options:
Since many people use Windows, PuTTY is a free and very popular terminal emulator supported by different network protocols such as SSH (Secure Shell), so it is a very good tool to connect remotely to servers. Here’s a step-by-step guide on how to connect to a server using PuTTY:
Termius is a powerful, modern, cross-platform SSH client designed for developers and system administrators. Termius is accessible on Windows, Linux, macOS, iOS, and Android to allow control of remote servers from any device. In addition to supporting SSH, Termius introduces additional features such as SFTP, key management, and team collaboration. Here’s a step-by-step guide to help you get started:
A free SSH client for Windows, Bitvise is a powerful, graphical user friendly one. What it offers besides being a primary SSH client is file transfer, tunneling (port forwarding), and remote administration, making it a very popular choice among users who require more than just a local SSH client. Here’s how you can get started with Bitvise:
1. Download Bitvise:
Go to the official Bitvise website and download one version of the Bitvise SSH Client. Also, be on the lookout for the correct version of what you need for your operating system.
2. Install Bitvise:
After downloading the installer, run it and follow the installation instructions. The setup process is straightforward, and once the installation is complete, you can launch Bitvise from your desktop or the Start menu.
With Bitvise, you have a comprehensive SSH client that goes beyond basic terminal functionality. It is excellent for users requiring advanced file transfer and tunneling capabilities in an easy-to-use GUI
But while using SSH, you will face different issues. Here are some common problems and how to resolve them:
If you encounter a connection timeout while trying to access your VPS, it might mean that the SSH service is currently not running. To resolve this issue, Restart the SSH service by executing the following command:
sudo service ssh restart

Make sure that your VPS is online and that you have set the correct IP address.
If you see a “Permission Denied” error while using SSH keys, ensure that your private key file has the correct permissions. You can set the appropriate permissions with the following:
chmod 600 ~/.ssh/id_rsa

Additionally, confirm that the public key has been properly added to the ~/.ssh/authorized_keys file on your server.
Ensure that your VPS firewall allows SSH traffic By running the following command:
sudo ufw allow ssh

If you are using a different firewall, such as iptables, make sure to configure it to allow port 22 (the default SSH port).
Cloud providers such as AWS or Google Cloud ensure that the SSH key pair, in this case, is assigned to your instance. For AWS, you can verify the key pair attached to your EC2 instance in the instance’s settings.
For users who frequently connect to multiple servers, using an SSH config file can streamline the login process. Here’s how to set it up:
Use the following command to open (or create) the SSH config file:
nano ~/.ssh/config
Input your server details in the following format:
Host my server
HostName 123.45.67.89
User root
IdentityFile ~/.ssh/id_rsa
After adding the configuration, save the file. Now, you can log in using a simplified command:
ssh myserver

This configuration eliminates the need to remember the IP address and other details for each server you manage.
SSH also provides secure methods for transferring files between your local machine and the server.
Secure Copy Protocol (SCP) allows you to transfer files securely over SSH. The basic syntax is:
bash
scp /local/path username@server-ip:/remote/path

Example:
bash
scp ~/localfile.txt [email protected]:/home/root/

Secure File Transfer Protocol (SFTP) is an interactive file transfer program that runs over SSH. You can start an SFTP session with:
sftp username@server-ip

Once in the SFTP shell, you can manage files using commands like put, get, ls, and cd.
SSH can also be used for port forwarding, which lets you tunnel network traffic through the SSH connection. It is very helpful if you want to connect to services running on your VPS that are not accessible publicly.
To set up local port forwarding, use the following syntax:
ssh -L local_port:localhost:remote_port username@server-ip

For example, to forward your local port 8080 on a web server running at port 80 on your VPS:
bash
ssh -L 8080:localhost:80 [email protected]

You can then access the web server by navigating to http://localhost:8080.
SSH is an important remote access tool for securely managing Linux VPS servers, providing flexibility and strong security. Regardless of whether you’re going with traditional password-based authentication, using key-based logins for added security, or using pre-generated keys that cloud platforms such as AWS or Google Cloud ship with services, you’ll want to know how to configure SSH and troubleshoot the tool itself.
Tools that make connecting to the Linux VPS easy for Windows users include PuTTY, Termius, Bitvise, and Xshell. More advanced features of the server can include the transfer of files and port forwarding.
This tutorial enables you to manage your Linux VPS securely using SSH, troubleshoot common issues, and accomplish your server management tasks with ease. Learn how to use SSH to streamline your workflow and make your server management that much easier. With practice and familiarity, you’ll find SSH a valuable addition to your toolkit for efficient server administration.

Vinayak Baranwal wrote this article. Use the provided link to connect with Vinayak on LinkedIn for more insightful content or collaboration opportunities.