How To Generate SSH Private And Public Keys

Categories: linux

Using ssh keys to administer remote devices is a must, In this guide we will be using two machines, the first machine the client is running parrot OS a Linux pen testing operating system and the second machine is running Ubuntu server 18.04.

First things first on the client machine open up a terminal and as always check for updates. We will also make sure the necessary packages are installed

sudo apt update && sudo apt upgrade && sudo apt install openssh-server

Once the system is done updating and installing the required packages we can proceed to create the public and private keys from the users home directory

cd ~/
ssh-keygen -t rsa -b 4096 -C client-machin

When it prompts you to enter a file in which to save the keys press enter to accept the default location, It will now prompt you to enter a password to protect the key file , you can hit enter to bypass setting a password, I normally don’t use a password for my keys that way i can ssh into remote machines without the hassle of typing out a password.

Now that we have successfully created our key pair we need to send the public key to the remote server.

Sending the key to the server can be achieved with a simple command.

ssh-copy-id -i $HOME/.ssh/ user@servers-ip

If everything went as planed we can now ssh into our server machine via the client machine without having to type in a password.


    Leave a Reply

    Your email address will not be published. Required fields are marked *