This is the 8th day of my participation in the August More Text Challenge. For details, see:August is more challenging
Here are some of the things you can do to get a new server.
This paper is based on CentOS7
Create a user and set a password
# Add user
sudo adduser admin
# Check whether it is created
ls /home
# Set user password
passwd admin
Log in to a user and add a user group
Log in as user admin
su -l admin
Add a user to the root group
sudo usermod -G root admin
If you don’t want to share the root account directly but need a way to switch to the root user, you can refer to this.
Log out of the admin user account and change the password as user root
vim /etc/sudoers# Add the following to the Settings, save need to enter wq! This file is read-only by default
admin ALL=(ALL) ALL
Sudo su # test whether you can switch to root
Incidentally, change the server name
hostnamectl set-hostname levin-box
Take effect immediately, but the current terminal needs to exit:
Use a male key to access the server
The following operation usually generates a PEM key file on the cloud server and uses this key to access the login. The command is as follows:
SSH -i yourserver.pem leixuewei\ @yourserverip # Ssh-i hello-ali-cloud.pem leixuewei\@63.88.88.192 Then enter the user password to log in to the server.Copy the code
Another, use SSH pub key to log in without password.
This is to add id_rsa.pub in the authorized_keys file in the target server to achieve password-less login
# SSH leixuewei @63.88.88.192 # SSH leixuewei @63.88.88.192Copy the code
.pem can be a public key or a private key, while.pub is the public key \ used by OpenSSH
If you are a local user, put id_rsa under your /home/leixuewei. SSH /. If you are a remote user, put id_rsa under your /home/leixuewei. Put id_rsa. The content of the pub put appended to the/home/leixuewei /. SSH/authorized_keys file.
Note that the “leixuewei” we see here is the user name. If you change the user path, it will be different.
Continuous learning and continuous development, I am the Lei School committee! Programming is fun, but the key is to get the technology straight. Creation is not easy, please support a lot, click like collection to support the school committee!