In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the method that Mac uses the secret key to log on to the Linux server, which has a certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
Brief introduction
Configure the SSH key to log in to the remote Linux on Mac
Related configuration
1. Create a local SSH key
Generate secret key pairs locally
Ssh-keygen-t rsa-C 'youxiang@aliyun.com'
-t specifies the key type. By default, rsa-C sets the comment text, such as your email address.
You can set the private key password. The password I set here is 12345.
The generated key is in the .ssh directory under the home directory by default.
two。 Upload the public key to a remote Linux server
Use scp to copy the public key to a remote server
Scp-P ~ / .ssh/id_rsa.pub @: / home/id_rsa.pub
The root user I use here to upload, you need to enter the login password
Configure the private key of the remote Linux
3. Log in to the remote Linux server and append the public key to the server ssh authentication file:
Cat / home/id_rsa.pub > > ~ / .ssh/authorized_keys
If you don't have a .ssh directory or an authorized_keys file in your home directory, you can create it and grant the authorized_keys file 600th permission
Then execute cat / home/id_rsa.pub > > ~ / .ssh/authorized_keys
4. Local ssh connection
Ssh-p @
5. If the default port is not modified, the port number can be ignored
Ssh root@114.11.11.111
Create a profile to log in quickly
You need to enter the user and ip address every time you log in, which is too troublesome. You can add a profile and log in using an alias.
Vi / .ssh/config
Host alias # Custom alias HostName 114.11.11.110 # replace with your ssh server ip or domainPort 22 # ssh server port. The default is 22User root # ssh server user name IdentityFile ~ / .ssh/id_rsa # the private key file corresponding to the public key file generated in the first step
You can log in using ssh jd at this point
Linux is prohibited from using account password to log in
1.cd / etc/ssh/
two。 Modify the configuration file vi sshd_config of SSH
RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh / authorized_keys#AuthorizedKeysCommand none#AuthorizedKeysCommandRunAs nobody# default PasswordAuthentication is yes, that is, password login is allowed. When changed to no, password login to PasswordAuthentication no is prohibited.
3. Restart the ssh service
Systemctl restart sshd.service
Thank you for reading this article carefully. I hope it will be helpful for everyone to share Mac's method of using the secret key to log on to the Linux server. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.