-->

Wednesday, November 30, 2016

Setting Stricthostkeychecking and SSH session timeout on Linux Server

While working on the Linux server its common to face the ssh session timeout from the server due to ideal session. Although you can prevent the session timeout from the server and client.

Setup the ServerAliveInterval in your user account to provide the extended time for session timeout i.e. 120 seconds

 vim .ssh/config  

 Host *
   ServerAliveInterval 120

 chmod 600 .ssh/config

If you are using the Bastion host in your corporate environment to connect to the Different Server than you can edit the sshd_config file  and make an entry as below to increase the session timeout for the ssh

 vim /etc/ssh/sshd_config  

 ## ssh ideal timeout value
  ClientAliveInterval 120



Than you need to restart the ssh service to make this effective.

Lastly is the Settings in the putty , so once you open the putty select the default settings---> Connection---> Seconds between Keppalives (120)---> click Apply--->Click Save

Also Every time you connect to the New server it asks for the key checking and if you are working in an autoscale environment and have created the automated scripts using the ssh than those would not run unless you access the fingerprint and add the servers under your knownhosts in the Linux.

To over this you need to add the following configurations in your ssh settings

 Host *  
 StrictHostKeyChecking no
  UserKnownHostsFile=/dev/null
 User ec2-user

Since the ec2-user is the default user provided by the AWS to login to the server first time so you won't have to enter the username again and again while accessing different servers, it would be added by default to the ssh command everytime you access the server. Also the fingerprint would be automatically accepted and added to known hosts after you make this entries in your ssh.

0 comments:

Post a Comment