SSH on Linux distributions is commonly used to connect from other devices remotely to your Linux VPS server. To use the SSH service on your Linux device or your server, you need to create two SSH keys: one public and one private key.
First, you need to connect to your Ubuntu Server With SSH Using PuTTY application if you are using Windows. And if you are using other operating systems, you can connect to your server from their normal terminal.
If you don’t have an Ubuntu VPS for yourself yet, you can buy an Ubuntu VPS and get starting in few minutes. then connect securly using the SSH keys you will generate following this article.
To use the SSH connection protocol with key authentication method instead of logging in with username and password every time, and generating SSH keys.
We will use the ssh-keygen command to generate keys. First, make sure you’ve installed OpenSSH correctly.
ssh -V
If it returns your OpenSSH version, it means you’ve installed it successfully and follow the steps below to create keys; otherwise, read the article for Installing OpenSSH on Ubuntu.
SSH keys have many types, including ed25519, which is a modern standard type, and an older and universally compatible type called RSA. You can see commands for creating both of them below:
ed25519 type:
ssh-keygen -t ed25519
RSA type:
ssh-keygen -t rsa -b 4096
After entering the command, it will ask you for a destination for saving the SSH keys. You can specify a destination for it, or you can leave it empty and press Enter to use the default destination, which is recommended.

Here in this step, you will be prompted to set a password for your keys. You can leave it empty and press Enter to continue. But it would be more secure if you set a password.

After setting the password, you will see information about the generated key, like the fingerprints and random pattern generated for your key, and the location that your files are stored. You can navigate to that location to verify the file creation.
This is the default location where your keys are stored if you don’t change the destination path:
/home/username/.ssh
To verify if your SSH keys are generated or not, you can open your SSH public key file and verify if its content is in the correct format or not.
Running this command, you can see the content of your public key file.
cat ~./.ssh/id_ed25519.pub
You will see output like this:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJa5yjA7UAGGiMYfbquPRMqY6+3lJZ/9NCxIHm45UOAb root@linux
With the SSH key created, you can connect to other Linux servers from your Linux device, or if you are using a Linux server, you can accept incoming SSH connections with a key request.
For connecting to your Linux server, you need to copy your SSH key to the destination server, which you can do it manualy by copying it to the ~/.ssh/authorized_keys file or you can use this command to automate this proccess.
ssh-copy-id username@server_ip
After running this command, you will be prompted to enter a password. You should enter the passphrase you set when generating your SSH key. This is only required for the first connection.
For future connections, you don’t need to use the command above; you can simply connect using the standard SSH command.
ssh username@server_ip
These are some issues you may encounter when creating an SSH key on your Ubuntu VPS server. Even small problems can lead to connection or authentication failures.
It is important to follow each step carefully. SSH connections are critical because they are very important for your system security.
This is one of the main and common issues you can face when you are using the ssh-keygen command; it says ssh-keygen is not recognized.
For fixing this issue, you need to install OpenSSH on your Ubuntu server to fix it. It is usually not installed on Linux distributions automatically; you need to install it manually.
Sometimes, SSH key creation or usage can fail due to incorrect permissions on the .ssh directory. You need to set the correct permissions on your Linux server. SSH requires strict permissions for security reasons, and if your permissions are open to everyone, it may be ignored.
It’s better to have permissions like:
| Filename | Permission | Command |
|---|---|---|
| .ssh Directory | Full access to root user | sudo chmod 700 ~/.ssh |
| Private Key | Read and Write access to root user | sudo chmod 600 ~/.ssh/id_ed25519 |
| Public Key | Readable for all users and modifiable by root | sudo chmod 744 ~/.ssh/id_ed25519.pub |
When generating a new SSH key, you will be warned whether you want to overwrite the existing key; this action would cause problems if the previous key was already being used. To avoid this issue, you can back up your SSH keys, or you can take backup of your Linux VPS.
You may also encounter silent connection issues, where everything is configured correctly, but you still cannot connect. This can happen if your Linux server firewall is blocking SSH traffic, especially on port 22 (and in some cases other ports if they were changed from the default).
You can fix this problem by opening the specified port for SSH on Linux firewall.
SSH is the key connection type to Linux servers, and if you want to make it more secure, you can use SSH keys to avoid using a username and password on every login. We covered how you can create it on your Ubuntu server in this article and explained the common issues you may face.
If you want to connect with SSH key pairs from a Windows device, you need to create SSH keys on Windows, too.