Skip to main content

Key-Based ssh Login


In this post we will look at how to use ssh key-based login.


Generate SSH key pair
ssh-keygen -t rsa -b 4096

SSH into the destination server and add the content of id_rsa.pub to remote server authorized_keys file
vim authorized_keys

If .ssh directory or .ssh/authorized_keys file is not available, follow the below instructions to create them,
create .ssh directory
vim authorized_keys

Set the right permissions
chmod 700 ~/.ssh

Create the authorized_keys file
touch ~/.ssh/authorized_keys

Set the right permissions
chmod 600 ~/.ssh/authorized_keys

[prea class="language"]
  ls -al
  [/prea]
  

ls -al
preaa
Source1, Source2

How to generate a key pair in MobaXterm?

Enter the following command in the MobaXterm terminal
[pre class="brush:bash"]ssh-keygen -t rsa -q -f ~/.ssh/id_rsa[/pre]
This will generate the private and public key pair inside .ssh folder located in your home directory (source).

You may also interested in reading:

Comments