Your Complete Guide to Connecting to a VPS

Yawar Osman
3 min readDec 13, 2023

--

Introduction

Hello, digital adventurers! Today, we’re diving into the world of Secure Shell (SSH), a vital tool for managing Virtual Private Servers (VPS). Whether you’re a developer, system administrator, or just a tech enthusiast, understanding how to connect to a VPS using SSH is a crucial skill. This comprehensive guide will walk you through every step of the process, from generating keys to establishing a secure connection. Let’s get started!

Understanding SSH

SSH, or Secure Shell, is a protocol used to securely access and manage remote systems. It’s widely used for a variety of tasks like file transfers, remote server maintenance, and more. SSH is favored for its robust security, which includes features like encryption and authentication.

Step 1: Generating SSH Keys

SSH keys are a pair of cryptographic keys that can be used to authenticate to an SSH server as an alternative to password-based logins. A private key, which is secret, and a public key, which is shared. Here’s how to generate them:

  • On Windows: Use a tool like PuTTYgen. Open PuTTYgen, select the type of key to generate (RSA is a good choice), and click “Generate”. Move your mouse randomly in the area as instructed until the key is generated. Then, save both your public and private keys.
  • On macOS and Linux: Open your terminal and run the command ssh-keygen -t rsa -b 4096. This creates a new SSH key, using the provided email as a label. When prompted to "Enter a file in which to save the key," press Enter to accept the default file location. At the prompt, type a secure passphrase for an extra layer of security.

You can find you keys on .ssh folder under the root folder

Step 2: Installing the Public Key on Your VPS

Now, you need to install your public key on your VPS. This process varies slightly depending on your VPS provider but generally involves accessing your server’s control panel and pasting your public key into the appropriate field. Some providers allow you to paste the key directly into the server setup form when creating a new server.

Step 3: Connecting to Your VPS via SSH

  • On Windows: You can use a client like PuTTY. Enter your server’s IP address, specify the port (usually 22 for SSH), and under Connection > SSH > Auth, browse to select your private key file. Then, open the connection and when prompted, enter your username (often root for Linux servers).
  • On macOS and Linux: Open your terminal. Use the command ssh [username]@[server-ip-address] – replace [username] with your server username and [server-ip-address] with your server’s IP address. The first time you connect, you'll be asked to confirm the server's fingerprint. Type yes, and if you used a passphrase when creating your SSH key, enter it when prompted.

Step 4: Navigating Common Issues

  • Permission Denied Error: This usually means there’s an issue with your SSH keys. Ensure your public key is correctly installed on your VPS and your private key is correctly referenced in your SSH client.
  • Connection Timed Out: Check your internet connection, ensure your VPS is running, and confirm that the IP address and SSH port you are using are correct.

Conclusion

Congratulations! You’ve mastered the art of connecting to a VPS using SSH. With this skill, you’re well-equipped to manage your servers securely and efficiently. Remember, the security of your server is paramount, so always keep your private key safe and use strong, unique passphrases.

Have questions or tips about using SSH? Feel free to share them in the comments below. Happy SSH-ing!

yawarosman.com

--

--

Yawar Osman
Yawar Osman

Written by Yawar Osman

Project Manager || Software Developer || Team Leader || Flutter Developer

No responses yet