Show Categories

How to Connect to A Linux VPS Using SSH Keys in macOS Terminal

In this guide, we will explore the process of generating SSH keys in macOS Terminal, importing them to the Cloudzy Portal, and establishing a secure connection to your Linux VPS. With SSH keys, you can fortify your server's security, simplify remote access, and manage your VPS efficiently through the macOS command-line interface.

Understanding Terminal in macOS

Terminal serves as a terminal emulator on macOS, providing users with a text-based command-line interface to the Unix shell. This powerful tool enables direct interaction with the operating system, facilitating a wide range of tasks and system operations.

To open the macOS Terminal, follow these steps:

  1. Launch Finder and select Utilities from the Applications folder.
  2. Locate the Terminal in the Utilities list and open it.

Generating SSH Keys on macOS

SSH keys consist of a private and public key pair, where the private key must be kept confidential, and the public key allows secure login to your provisioned Linux VMs. To generate SSH keys in macOS, follow these steps:

  1. Launch the Terminal application on your macOS system.
  2. Execute the following command in the Terminal window:
ssh - keygen - t rsa

The key generation process will prompt you to specify the storage location for the keys. Accept the default location by pressing the ENTER key, and set a passphrase for enhanced security (not recommended to skip this step).

⚠️Warning! You will need to enter the passphrase twice to continue.

After confirming the passphrase, the system generates the key pair.

one

Your private key is saved to the id_rsa file in the .ssh directory, while the public key is stored in id_rsa.pub.

⚠️Important: Never share your private key with anyone!

Save the public key to your clipboard by running this command:

pbcopy < ~/.ssh/id_rsa.pub

Importing Your SSH Key to the Cloudzy Portal

Now, import the copied SSH key to the Cloudzy Portal for secure server management:

After copying the SSH key to the clipboard, return to your Cloudzy account page.

In the left sidebar, choose SSH Keys and click on NEW SSH KEY in the top right corner.

Name your key descriptively and paste the id_rsa.pub contents into the Public Key area.

two

With your SSH key is successfully imported, you're well-prepared for streamlined VPS creation and heightened server security.

three

Connecting to Your VPS via Terminal

Now, let's explore the process of establishing a secure connection to your VPS server through macOS Terminal, and gain a deeper understanding of the SSH -i option for enhanced security:

  1. Launch the Terminal application on your macOS system.
  2. Compose the following command in the Terminal, ensuring you replace username with your virtual private server's username and "your_server_ip" with your server IP address or domain name:
ssh username @your_server_ip
  1. If this marks your initial connection, you will be prompted to confirm the authenticity of the host and subsequently enter the passphrase you designated for your SSH key during its generation.

Introducing the -i Option: To elevate the security of your connection, you can make use of the -i option followed by the path to your private SSH key. This mechanism is founded on key-based authentication, which adds an additional layer of protection by allowing only individuals with the associated private key to access the server.

ssh - i / home / username /.ssh / id_rsa username @your_server_ip

By integrating the -i option and specifying the complete path to your private SSH key, you are fortifying the security of your connection.

You now know how to easily connect to a Linux VPS from macOS using SSH keys. If you have any questions, feel free to contact our support agents by submitting a ticket.

FAQ

Is setting a passphrase during SSH key generation necessary?

While setting a passphrase is optional, it is highly recommended for added security. The passphrase acts as an additional layer of protection for your private key. If you skip this step, anyone with access to your private key can potentially gain unauthorized entry to your VPS.

Can I use my SSH key for multiple virtual private servers?

Yes, you can use the same SSH key to access multiple servers. Once you have imported your SSH key to the Cloudzy Portal, you can select it from the advanced options when creating new VPS instances, enabling you to manage multiple servers seamlessly.

Is it safe to store my private key on my macOS system?

It is essential to keep your private key safe and confidential. By default, your private key is saved to the id_rsa file in the .ssh directory on your macOS system. Ensure that you do not share or expose your private key to unauthorized individuals, as it grants access to your VPS instances.

Can I revoke or delete my SSH key from the Cloudzy Portal?

Yes, you have the option to manage your SSH keys on the Cloudzy Portal. If needed, you can remove or delete SSH keys from your account. However, it's important to note that revoking an SSH key from the Cloudzy Portal does not automatically remove the key from the actual VPS it was associated with. You may need to manually revoke the key from the VPS itself to ensure that unauthorized access is prevented.

cloudzy
© 2008-2024 Cloudzy. All rights reserved.
75 Reviews|4.9 Average