How Can We Help?
< All Topics
Print

Enhancing Security: A Guide to Using SSH Keys on Your VPS

SSH, also known as Secure Socket Shell, is a network protocol that provides secure access to computers over unsecured networks and includes a set of utilities that implement the SSH protocol.

a) How to generate SSH keys for Linux

VPS

1. First, open the terminal and enter the ssh-keygen -t rsa command to generate a pair of keys.

Note: The file name and file save destination may need to be selected based on your Linux version.

2. The default path for saving keys is /root/.ssh, where id_rsa is the private key and id_rsa.pub is the public key.

b) How to generate SSH keys for Windows

1. First, download the Putty software from the Putty website and open it.

2. Then, click the Generate button and drag your mouse over the empty field.

3. Finally, your key will be generated at the end.

c) Remove SSH key authentication and re-enable password authentication

1. First, open a terminal and enter the nano /etc/ssh/sshd_config command there, changing it back to “yes“.

2. Then, delete the .ssh folder and its contents using the rm -R /root/.ssh command.

3. Finally, use the systemctl restart ssh command to restart the ssh service.

d) How to use SSH private keys with PuTTY

1. First, open the Putty software and click “Connect” to expand.

2. Then, click “[+]” next to “SSH” and then click “Authentication” to open a window on the right.

3. After that, click on “Browse” to select your private key.

4. Next, scroll to the left, click on Sessions, enter the server’s IP address, and then choose the profile name in the Saved Sessions field.

5. Finally, click the Save button to save your configuration file.

e) How to upload an SSH public key to your server

FTP

1. First, open FTP and connect to the server as root.

2. Then, use the .ssh command to create the following directory in the root directory.

3. Finally, create an authorized_keys text file in the specified folder and paste the entire public key into it, then save the file.

Console

1. First, use SSH to log in to the VPS as root, enter the mkdir /root/.ssh && cd /root/.ssh commands to create the correct directory, and switch to the directory at the same time.

2. Then, use the nano authorized_keys command to create and open the authorized_keys text file.

3. Finally, paste the entire public key and press [CTRL+O] to save the file.

4. To exit the editor, use [CTRL+X].

Table of Contents