English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Use the user's private key to connect to the host via ssh, which is much more secure than entering root's password directly. For specific implementation, please refer to the tutorial below.
PS: Perform operations with root privileges
1) First create an account
// Create an account lee, belongs to group wheel useradd -d /home/lee -g wheel lee
After executing/Create a directory named lee under home. The directory permissions are700, belongs to group wheel, belongs to user lee
2) in /home/Generate the .ssh directory under lee
// Generate the .ssh directory, permissions are700 mkdir -m 700 /home/lee/.ssh
3Create authorized_keys)
touch /home/lee/.ssh/authorized_keys
// Modify the permissions of the authorized_keys file600 chmod 600 /home/lee/.ssh/authorized_keys
4ssh client generates keys, here using xshell as an example)
Click "Tools", select "New User Key Generation Wizard"
Click "Next"
Click "Next"
The password for encrypting the key can be omitted. This password is only used for the verification of xshell itself.
Save the file as "lee.pub", and remember the directory where lee.pub is placed.
After clicking "Finish", the key created will appear in the user key list as shown below:
The key generation task is done to this point.
5Copy the content of lee.pub to the authorized_keys file)
Please copy using vi yourself, it will not be displayed here.
6ssh information for xshell)
Click "User Authentication"
7Test connection)
Before connecting, be sure to change the permissions. If the permissions are not changed, all the work done before will be invalid. Please be careful!!!!!
// Modify/home/lee/The permissions of the directory are700 chmod -R 700 /home/lee/ // Modify/home/lee/The owner of the directory is lee chown -R lee /home/lee/ // Modify/home/lee/The group ownership of the directory is wheel chgrp -R wheel /home/lee/
Click "Connect"
If you see the figure as shown, congratulations, you are OK.
Command to switch to root account
sudo su
If root has a password, then you need to enter the password.
That's all for this article. I hope it will be helpful to everyone's learning and also hope everyone will support the Yelling Tutorial more.
Statement: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume any relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (Please replace # with @ when sending an email for reporting, and provide relevant evidence. Once verified, this site will immediately delete the infringing content.)