Skip to main content

SSH - Creating a keygen to automatically logon to remote servers


csr@MainPC:~/Downloads$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/csr/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/csr/.ssh/id_rsa
Your public key has been saved in /home/csr/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:LAkXcDEfDYkzGq/aWJoL0ViHPvwsbxg9NOfeujAgyMg csr@MainPC
The key's randomart image is:
+---[RSA 3072]----+
|    ..=oo+       |
|   ...++...      |
|  o o+.o.        |
|=* .+ooo         |
|*E*o =o S        |
| o.== ..         |
|. .X=o .         |
| .*ooo. .        |
|  .o. oo         |
+----[SHA256]-----+
csr@MainPC:~/Downloads$ ssh-key
ssh-keygen   ssh-keyscan  
csr@MainPC:~/Downloads$ ssh-key
ssh-keygen   ssh-keyscan  
csr@MainPC:~/Downloads$ ssh-copy-id [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/csr/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.

csr@MainPC:~/Downloads$ ssh 192.168.10.218
Web console: https://rhel-lab1.htf.com.mx:9090/ or https://192.168.10.218:9090/

Last login: Tue Apr  9 16:00:47 2024 from 192.168.10.209
[csr@rhel-lab1 ~]$