Suitable for VPS novice users several common SSH commands and usage collation

Source: Internet
Author: User
Tags new set ssh vps ssh port
The day before yesterday the old left has helped a netizen to purchase a Linode VPS host, this friend after use various complains that the connection SSH will break out in a short time, has made a lot of complaints need to provide a solution. After all, although the VPS performance is not as good as before but generally not so unstable, it should be the default SSH timeout setting problem, so given the setting parameters do not appear after the timeout is kicked out of the problem.

Similar to this tutorial online or relatively complete, the old Zoshun belt together we have the possibility of novice will be used and the old left some time also did not learn the common SSH commands and usage sorted down, so that the next time you need to encounter problem solving and learning to do a summary document. Here is probably sorted to the common 7 uses, in fact, about the use of various SSH details or more (in the SSH client all operations can be attributed).

First, prevent SSH login timeout kicking out the problem

1. Modify/etc/ssh/sshd_config

Modify the Clientaliveinterval 0 and Clientalivecountmax 32 lines in the/etc/ssh/sshd_config file, remove the front #, and then modify to 60 and 9999 respectively, so that the interval is set long for sending requests.

2, restart sshd

The code is as follows Copy Code

Service sshd Restart

This can take effect after restarting the sshd.

Second, modify the SSH port

Default we buy open VPS host will be used to 22 ports, but some similar to the relocation of a bricklayer VPS such will be random change port, one is to ensure the security of the server, if we do not use the key link SSH when the proposal or modify 22 port, although it can not be said that someone deliberately destroyed, But some automated software can also be swept to increase the burden and risk of the server.

1,/etc/ssh/sshd_config

Edit the file, then locate the Port 22 script location, and if there is a # in front of it, remove 22 and replace it with another number.

2, restart sshd

The code is as follows Copy Code

/etc/init.d/sshd restart

The Execute command reboot takes effect, so that we use the new set of ports whenever we log in with SSH or SFTP.

Third, the root user is prohibited

The same above default is 22 port, where we use the VPS default is root, we can add a user name we know, and then the default root user is prohibited.

The code is as follows Copy Code

/etc/ssh/sshd_config

Modify the "#PermitRootLogin yes" in this file, remove the front #, modify it to no and then we restart SSH to take effect, we need to authorize a different user in advance, or we can not get in before we close.

Iv. new users with normal rights

Here need to insert a word, old left all the Bowen is only a record of personal information, does not represent authority, we in the reference to use the best time in the test machine to operate, the practice of successful after the actual use. For example, we can not ban the root user before adding users, or we can not get in. You must add a user

The code is as follows Copy Code

Useradd Laozuo
passwd Laozuo

Then there is a need to give Laozuo this user set two times password. Then we prohibit the general operation of the root after the ordinary users, if you need to use the root of the time su-root switch past.

V, Remote link host

The code is as follows Copy Code

SSH username@ipaddress
SSH ipaddress-l username

We can use this method to link the current server to a remote designated user and IP address server.

The specified port to connect to the remote server

The code is as follows Copy Code

SSH username@ipaddress-p 22
SSH ipaddress-l username-p 22

Similarly, we can use the ssh-l username ipaddreee ' command ' to remotely obtain information and operations on remote servers.

VII, modify the Welcome language of login SSH

For example, when we log on to some VPS users will see such a prompt welcome language, generally no use, can be fake. We can also set up such information for our own machines, or give you the hint of login ssh that is provided to the client, which appears to be your presence.

The code is as follows Copy Code

/etc/motd

Edit this file, put the welcome language in, and then restart SSH to take effect. But old left also see some tutorials refer to the use of the/etc/ssh/sshd_config file in the banner definition path, but I set no effect, but above this has effect, it is not clear what the reason is not the release version of different methods.

To sum up, there are many uses for SSH, such as copying, backing up, moving files, and all SSH-side operations can be attributed to SSH, with 7 applications being just some of the records that may have been encountered.

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.