How to Create Passwordless SSH Private/Public Key Pair on Ubuntu



An SSH key pair is needed to connect to an SSH server. It is possible to create a passwordless key pair so as to bypass the password prompt when you connect to your SSH server. This is handy for when you need to automate some processes through scripting. Follow the instructions below to create a new passwordless key pair:


1. Install OpenSSH. On Ubuntu, you can install OpenSSH by opening your terminal and typing:

sudo apt-get install openssh-client

2. Once OpenSSH is installed, stay in the terminal and type:

ssh-keygen -t dsa -f ~/.ssh/id_dsa

3. When prompted for a password, leave blank and hit enter, then enter again to confirm. Your key pair will be created and stored in ~/.ssh/ as id_dsa.pub [public key] and id_dsa [private key]

Next, you will need to copy the contents of id_dsa.pub to a file named authorized_keys and transfer the file to the target system you wish to connect to. Follow the instructions below:

1. Create the new file with the following command:

touch ~/.ssh/authorized_keys

2. Apply the correct permissions:

chmod 600 ~/.ssh/authorized_keys

3. Copy the contents of id_dsa.pub to the new file:

cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

Finish by transferring the new file to the target server. You should now be able to connect to your SSH server without having to enter a password.

Source from here




0 comments: