Use a key to log on to the CentOS System (key-based authentication)
When servers are deployed on the internet, there may be many security risks on a regular basis. Many people will try to log on to your server using various account and password for various purposes, to prevent other users from logging on to the server with their passwords, We can configure ssh. Without a password, we only use the public key and private key for verification, in this way, the server security can be improved to a certain extent.
There are a variety of software on the Window client that can log on to ssh, such as putty, xshelll, and secureCRT. I will use xshell as an example to set the public key and private key to verify the login server.
Use the Xshell key authentication mechanism to remotely log on to Linux
1. Use xshell to generate a Public Key
Select DSA for Key Type (SSH1 only supports RSA, SSH2 supports your own version) and click Next to generate a public/private Key.
Set the key name at will. Here I keep the default value.
Passphrase is the key password. If you do not set Passphrase, you can log on to the server as long as you have the key. If you set the password, you must have the key and password to log on to the server. For the sake of security, set the key password.
Click Next
Select Save as a file to Save the public key. The public key and private key must be properly saved.
Click Finish
Click Close to Close the key. You can also click Expoet to export the private key. The private key can be exported at any time.
When exporting the private key, you are prompted to enter the password. Enter the password.
2. Create a user using the key
# Useradd zsl
# Passwd zsl
# Su-zsl
$ Mkdir. ssh
$ Chmod 700. ssh/
Upload the created public key to the. ssh/directory.
$ Cd. ssh/
$ Cat id_dsa_1024.pub> authorized_keys
$ Chmod 600 authorized_keys
3. Modify the ssh configuration file
$ Su-
# Vim/etc/ssh/sshd_config
Changes
PasswordAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile. ssh/authorized_keys
# Service sshd restart
3. log on to the server
After the user name is entered, "password" is gray and cannot be used. That is to say, the user name and user password cannot be used to log on to the server. Select the private key corresponding to the server and enter the key and password.
4. If other clients want to log on to the server, copy the Private Key to the client. When selecting the key, select "Browse" and select the correct key and enter the password.
Troubleshooting of Chinese garbled characters when Xshell logs on to CentOS 6.3
VirtualBox4.12 text installation CentOS 5.4 and Xshell connection tutorial PDF
Xshell connects to CentOS6.5 iptables or ls to output garbled characters
Use Xshell to log on to VMware Linux