SSH Commands

less than 1 minute read

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

Source1, Source2

How to generate a key pair in MobaXterm? Enter the following command in the MobaXterm terminal

ssh-keygen -t rsa -q -f ~/.ssh/id_rsa

This will generate the private and public key pair inside .ssh folder located in your home directory (source).

Copy ssh key to remote machine

#from local machine
ssh-copy-id -i ~/.ssh/id_ras.pub pi@<ip address>

# from github
sshssh-import-id-gh

Tags:

Categories:

Updated:

Comments