Connect SSH without Password(Using Keys 🔐)
If you want to connect someone’s terminal access ….you should give them your ssh public keys
Example : Host to Guest
Windows to Ubuntu Server :
If you want to access Ubuntu Terminal
Windows should share his public key to Ubuntu
Step 1: Generate SSH Keys In a Separate Folder In Windows
i. Create .ssh folder in [Local: D] Drive
ii. Open the same folder in CMD
iii. Type this command and add your name in the place of suhail
ssh-keygen -t rsa -f D:\.ssh\vscode -C suhail -b 2048
iii. Press Enter 3 Times
iv. Type this command
type vscode.pub
v. Copy the whole key from ssh-rsa to last word suhail and store in it a file
Step 2:
Now Open Your Host Machine (Ubuntu Or That Guest you want to access that terminal)
Here We are Taking Ubuntu as Guest
i. Type this Command in Ubuntu
sudo nano /etc/ssh/sshd_config
ii. Set ChallengeResponseAuthentication no
ChallengeResponseAuthentication no
iii.Next, find PasswordAuthentication set to no :
PasswordAuthentication no
iv.Search for UsePAM and set to no, too:
UsePAM no
v.Finally look for PermitRootLogin and set it to no too
From PermitRootLogin prohibit-password to
PermitRootLogin no
vi. Then type this Command
sudo systemctl reload ssh
iv. To Exit From Terminal Ctrl + O and Ctrl + X
v. Type this command
nano authorized_keys
vi. Paste the Windows Key in authorized_key file
vii. To Exit From Terminal Ctrl + O and Ctrl + X
viii. Give File and Folder Permission to SSH
// Here file name is your file name of Public and Private Keys
cd
sudo chmod 700 .ssh
sudo chmod 644 filename.pub
sudo chmod 600 filename