SSH Timeout and Non-password Login

There are some inconveniences login via ssh.


The first thing is timeout, the sshd always drop connections after certain idle time interval by default, it’s really annoy if you are not care this secure consideration.
We can disable this timeout mechanism by adding the following configs into sshd configuration file.

# File: /etc/ssh/sshd_config
ClientAliveInterval 30 
TCPKeepAlive yes 
ClientAliveCountMax 99999

Non-password Login

We also can login via public keys instead of entering the password every time. Just run the following commands:

# Generate the ssh keys:
ssh-keygen -t rsa
# Copy the public key into hosts' authorized_keys
cat ~/.ssh/ | ssh user@ "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

We can then turn off the password login to secure our hosts:

# Edit: /etc/ssh/sshd_config
PermitRootLogin without-password



电子邮件地址不会被公开。 必填项已用*标注