First, SSH installation
To see if the system is installed try: Rpm-qa | grep OpenSSH, as shown is installed.
If the system is to install SSH, configure Yum to begin installing SSH.
Install command: Yum install-y openssh-server openssh-clients
Second, SSH to modify the secure connection port
If you use the default 22 port, it is easy to be scanned and attacked by chickens, so the SSH connection port will be modified basically for security purposes.
Before modifying the port, you can back up the configuration file, command: Cp/etc/ssh/sshd_config/etc/ssh/sshd_config.bak
Edit the configuration file: Vim/etc/ssh/sshd_config, remove the comment before Port 22, modify port 22 to 123456.
Restart SSH service:/etc/init.d/sshd restart
View SSH service usage port: Netstat-ntlup | grep ssh
If you have a firewall, you should first increase the rules for the modified SSH service port, or you will not be able to connect to the server remotely due to firewall restrictions.
Add rule: iptables-i input-p tcp-m tcp--dport 123456-j ACCEPT
Save rule: Service Iptables save
Restart Iptables:service iptables Restart
Note: since you have a/etc/ssh/ssh_config file, make sure that you modify the file correctly when you modify the configuration file.
Third, set the SSH timeout time
Parameter clientaliveinterval: Specifies the interval of time that the server sends a message to the client, with a default value of 0 indicating not to send, or 0
Modified to 300 indicates that the 5-minute server sends a message to the client, and if the client responds, it continues to maintain a long connection.
Parameter Clientalivecountmax: Indicates the maximum number of non-response times for the server to send the message client, if the set value is reached, then SSH
The connection is disconnected and the default value is 3.
Example: If setting the value of Clientaliveinterval to a value of 300,clientalivecountmax is 3, then the client is 15 minutes
The SSH connection will automatically exit if the server is not responding.
Linux basic SSH