Skip to main content

Establishing an SSH Connection to Your VPS (Mac OS)

Are you ready to create an SSH connection to your server for the first time after setting it up? Usually, the server hosting provider supplies you with the root password and a username (typically "root") to enable you to establish a connection. However, you might also use an SSH key for authentication. This guide presents step-by-step instructions for both scenarios:

1. Making a Connection Using the Server Password

To connect to your server instance, follow these steps:

  1. Prepare your connection details: You will need the following pieces of information:

    • Server IP-address (IPv4) or hostname
    • Username - this is often "root", but you may have created a different user during server initialization.
    • Server root password - your hosting provider usually provides this upon server setup.
  2. Access your terminal application: For macOS users, the "terminal" application comes pre-installed. Press command + space to bring up the Spotlight search and look for "terminal".

  3. Establish the connection: Input the following command into the terminal and press enter:

ssh <username>@<ip-address>

Remember to replace <username> with your actual username (e.g., root) and <ip-address> with your server's IP address or hostname.

  1. Trust the server: If you're connecting from your local machine to your server for the first time, SSH will prompt you to confirm if you trust the server. You can usually type y and press enter to confirm. For additional security, compare the displayed SSH key fingerprint with the one your server hosting provider supplied after server initialization. If both keys match, you're connecting to the right server.

  2. Enter your password: Input the password and hit enter. Although you can't see what you're typing, you can copy and paste the password.

Congratulations! You've successfully accessed your server console.

2. Making a Connection Using an SSH Key

In cases where an SSH key is preferred for authentication, follow these steps:

  1. Prepare your connection details: Ensure you have the following information:

    • Server IP-address (IPv4) or hostname
    • Username - often "root", but you might have created a different user during server initialization.
    • SSH private key file - this file is often located in your local machine's ~/.ssh directory.
  2. Access your terminal application: If you're using macOS, the "terminal" application is pre-installed. You can open Spotlight search by pressing command + space and search for "terminal".

  3. Establish the connection: To connect to your server using the SSH key, type the following command into the terminal, replacing <username>, <ip-address>, and <path-to-private-key> with your actual details, then press enter:

ssh -i <path-to-private-key> <username>@<ip-address>
  1. Trust the server: On first-time connections, SSH will ask if you trust the server. Normally, you can type y and press enter to confirm. To be extra secure, you can compare the displayed SSH key fingerprint with the one your server hosting provider supplied after server initialization. If they match, you're connecting to the correct server.

Congratulations! You have now successfully accessed your server console using an SSH key. It's a secure and reliable method of connecting to your server, especially when dealing with sensitive data or performing critical operations.