My scrapbook about almost anything I stumble upon in my tech world. If you find anything useful don't forget to give thumbs-up :)

Breaking

Wednesday, March 17, 2021

Enabling SSH access to localhost

To setup a Linux cluster which can communicate over SSH without passing password is pretty mundane activity for any linux administrator. But sometimes it's get little tricky to deal with, hence, in this post, I am going to share steps to setup SSH to localhost and how to verify if that is working. 

Step 1: Verify if SSH is installed 

sudo yum list installed | grep ssh

Step 2: Setup SSH Keys

ssh-keygen -t rsa -b 4096

Step 3: Configure Keys

ssh-copy-id atul@localhost   # atul will be change with your user
chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Step 4: Check and Edit SSH config 

Check below properties in your SSH config which reside at /etc/ssh/sshd_config

Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 1024
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
PermitRootLogin no
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
ClientAliveInterval 30
ClientAliveCountMax 99999

Next, You can start the SSHD service and check if Port 22 is open and listening -

sudo systemctl restart sshd
netstat -lnt | grep 22







Now, you can try to run SSH command to localhost, -v will verbose the whole process to make ssh connection to localhost, if there is any issue persist, verbose log will give us the idea.

ssh localhost -v  # verbose

This is all about setting up SSH to localhost.. see you guys with next post.. Till then..Happy Learning !!


Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Telegram Group

No comments:

Post a Comment

Disclaimer

The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.