Save the changes and restart the SSH service: systemctl restart ssh You will also need to open the SSH configuration file: nano /etc/ssh/sshd_configĪnd make sure the following lines exist and are not commented: RSAAuthentication yesĪuthorizedKeysFile %h/.ssh/authorized_keys You can create and then add the contents of the public key using the nano text editor: nano /root/.ssh/authorized_keys Next, you need to copy the public key into the authorized_keys file on the remote server. ssh directory on the remote server with the following command: mkdir /root/.ssh If the ssh-copy-id tool is not available on your system, you can log in to your server and do this manually.įirst, connect yo your server via SSH with: ssh connected, you will need to create a new. Upload the Public Key to the Ubuntu server manually Now try logging into the machine, with: "ssh check to make sure that only the key(s) you wanted were added.įrom now on, you should now be able to authenticate to your Ubuntu server using your SSH keys. The following output should be displayed: Number of key(s) added: 1 After the connection has been established, the contents of the id_rsa.pub (the public key) will be copied into the /root/ssh/authorized_keys file on the remote server. You can then use the following command to upload the public key to your remote server: ssh-copy-id will be asked to enter your user password (in our example that would be the root password) and press Enter. In order for this to work, you should be able to connect to your server via SSH using password authentication. The most simple way is to use the ssh-copy-id utility. There is more than one method to do this. The next step requires that you upload the generated public key to your remote Ubuntu server. Upload the Public Key to the Ubuntu 16.04 server with ssh-copy-id This will create a 2048 bit private and public key (id_rsa and id_rsa.pub) in the /root/.ssh/ directory on your local system. SHA256:2QB/eJ39/4N7Q3PRSghNJmglX6hh2pSqQ3uGHhfd7Og key's randomart image is: Your public key has been saved in /root/.ssh/id_rsa.pub. Your identification has been saved in /root/.ssh/id_rsa. Generating public/private rsa key pair.Įnter file in which to save the key (/root/.ssh/id_rsa):Įnter passphrase (empty for no passphrase): Optionally, you can also set a passphrase to add an extra layer of security, or just press Enter again if you don’t want to. You can just press Enter to leave the default values to all the questions. To generate the SSH key pair, simply run the following command from the terminal on your local Ubuntu 16.04 based computer: ssh-keygen Generating SSH keys on Windows based system with PuTTY and PuTTYGen Upload the Public Key to the Ubuntu server manually.Upload the Public Key to the Ubuntu 16.04 server with ssh-copy-id.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |