Last update at :2024-04-27,Edit by888u
Recently, we helped a friend who has never used a vps buy a vps. In order to satisfy his strong interest in learning, we will update more learning articles recently. Okay, nonsense is like dandruff, no, it should be nonsense so I won’t say more. Let’s get started.
We have taught you how to protect your vps security before, such as changing the login port [http://www.138vps.com/vpsjc/73.html] and logging in with a secret key [http://www.138vps. com/vpsjc/159.html], but there is another way, which is to prohibit root login, use another user name to log in, and then escalate the privileges when root permissions are needed. In fact, we don't really like this method. We suggest that it is best to log in with a secret key. However, today, I still want to share how to disable root login.
1. Add users
First, we use putty to log in to our vps, and add a user, assuming susu, enter the following command:
adduser susu
Then enter the following command to set a password for [susu] and enter the password twice.
passwd susu
As shown below
That bastard said that our password is too simple, 123456. No matter how you look at it, it is a very complicated password, okay? !
ok, if [successfully] appears, it still indicates that it is OK. Let's open another putty and try to log in with susu. We find that we can log in.
2. Elevate the rights of [susu]
Under normal circumstances, [susu] does not have root permissions at this time. If you don’t believe it, you can try [cd] to the [/root] directory. We need to enter the following command and enter the root password.
su root
You can switch to root user.
3. Prohibit root login
We use winscp to log in to our vps, edit this file [/etc/ssh/sshd_config], probably in the middle, there is a line that changes [PermitRootLogin yes] to [PermitRootLogin no], if it is found to be commented, comment it out (That is, the # in front of the line) Delete.
Then we use the putty opened by root to run the following command and restart ssh
service sshd restart
If you feel annoyed, you can just restart the vps.
Then we turn off the putty of root and try to log in with root. You will find that you cannot log in. Try logging in with [susu]. Everything is normal. When root permissions are required, just switch to root according to the second step. .
4. Conclusion
At this point, the tutorial seems to have been completed. You can easily curse "We SB", then add this site to the blacklist, and then easily close the web page.
However, this is not over
When you are very excited and plan to use sftp to transfer some short movies to your vps, you sadly find that the username [susu] cannot enter many directories. Of course, if you are so smart, you will definitely think that I will change the file [/etc/ssh/sshd_config] so that [root] can log in, and then change it back after the transfer is completed. I'm glad you came up with this method.
But there is a better solution, which is to let [susu] directly have [root] permissions.
Okay, we are not going to teach you how to do it below. This is something we highly do not recommend because it is extremely disgusting.
If you really want vps security, log in with a secret key, it is very easy to use. Tutorial address: http://www.138vps.com/vpsjc/159.html
Recommended site searches: US imitation brand space, high-defense US server, free ASP space application, US virtual host purchase, Hong Kong server, foreign server, Hong Kong server, icp website registration, Hong Kong proxy server, domain name service Business,
发表评论