Setting up SSH public key authentication on Ubuntu 18.04 is a simple and secure way to access your server over SSH. Here is a step-by-step guide to help you set up SSH public key authentication on your Ubuntu 18.04 server:
ssh-keygen -t rsaSource:www.lautturi.com
This will prompt you to enter a passphrase for your SSH key. It is recommended to use a passphrase to increase the security of your key. However, if you prefer not to use a passphrase, you can simply press Enter to leave it blank.
ssh-copy-id
command. First, log in to the server using the ssh
command and your username and password. Then, run the following command on the client machine:ssh-copy-id username@server_ip
Replace username
with your username on the server and server_ip
with the IP address of the server. This will copy your public key to the authorized_keys
file on the server.
/etc/ssh/sshd_config
file to enable public key authentication. To do this, open the file with a text editor and make sure that the following line is uncommented (i.e. does not have a #
character at the beginning):PubkeyAuthentication yes
sshd
service to apply the changes:systemctl restart ssh
ssh username@server_ip
Replace username
with your username on the server and server_ip
with the IP address of the server. If you set a passphrase for your SSH key, you will be prompted to enter it.
That's it! You have now set up SSH public key authentication on your Ubuntu 18.04 server.