Linux basic SSH

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.