SSH

Table of Contents

Generating SSH key for linux:

$ ssh-keygen -t ed25519 -C "your_email@example.com"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/atulyaraaj/.ssh/id_ed25519): /home/atulyaraaj/.ssh/id_ed25519-hostinger
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/atulyaraaj/.ssh/id_ed25519-hostinger
Your public key has been saved in /home/atulyaraaj/.ssh/id_ed25519-hostinger.pub
The key fingerprint is:
SHA256:WFn6BQE8X7iOQY8qfR0RmninW your_email@example.com
The key's randomart image is:
+--[ED25519 256]--+
|    .o.o..=+     |
|     .o.+*o..    |
|      ooB=.+.    |
|   . + .. o  . E.|
|  ..o..  . .. ..o|
+----[SHA256]-----+

Adding your SSH key to the ssh-agent

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_ed25519-hostinger

Adding a new SSH key to your account

$ cat ~/.ssh/id_ed25519-hostinger.pub

SSH into system:

$ ssh username@IP.ADDRESS

Issues:

After sshing to a remote server you might get this warning:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:GX/31tC3Ax6E9WMUtf8Bl4tALwAO2BXF
Please contact your system administrator.
Add correct host key in /home/atulyaraaj/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/atulyaraaj/.ssh/known_hosts:12
Host key for IP.ADDRESS has changed and you have requested strict checking.
Host key verification failed.

Solution:

$ codium /home/atulyaraaj/.ssh/known_hosts

Open known_hosts in your favourite editor and remove the entries related to that IP.ADDRESS where you were getting this warning.

SSH again, now it will add new details according to new key-pair generated.


Tags :