SSH (Secure Shell) is a protocol used for secure remote access to servers. When you connect to a server using SSH, you need to authenticate yourself using a username and password. However, you can also use SSH keys to authenticate yourself without entering a password. This is more secure and convenient than using a password.
In this article, we will show you how to set up SSH keys on a VPS.
The first step is to generate a new SSH key pair on your local machine. You can do this using the ssh-keygen command. Open a terminal window and run the following command:
ssh-keygen -t rsa
This will generate a new RSA key pair, consisting of a private key and a public key. The private key should be kept secret and never shared with anyone. The public key can be shared with servers you want to connect to.
Once you have generated your SSH key pair, you need to copy the public key to your VPS. You can do this using the ssh-copy-id command. Open a terminal window and run the following command:
ssh-copy-id username@your_server_ip
Replace "username" with your username on the VPS, and "your_server_ip" with the IP address of your VPS. You will be prompted to enter your password for the VPS.
After you have copied the public key to your VPS, you should test the SSH connection. Open a terminal window and run the following command:
ssh username@your_server_ip
You should be able to connect to your VPS without entering a password. If you are prompted for a password, something went wrong and you should check your SSH key setup.
Setting up SSH keys on a VPS is a simple but effective way to improve the security and convenience of your server access. By following the steps outlined in this article, you can generate a new SSH key pair, copy the public key to your VPS, and test the SSH connection.