This article was originally published on our official account: ReactNative development circle.

Recently I just bought a CentOS server of Tencent Cloud. I found someone cracking the root password by violence just one day. The cracking times are very high, and there have been thousands of times. Look at Tencent cloud is to support SHH key login, so toss over and over again.

Server side Settings

Tencent cloud background can directly set the SHH key, and then bind the corresponding server. First of all, we need your own key, so it’s more secure.

Locally generated key

ssh-keygen -t rsa

This command can be executed, the first will ask you where to save the key, here you can directly press Enter, and then set the key password, need to enter twice. The key is then generated successfully. And then it tells you where the key file is, go to that location, open the.pub file, this is the public key, copy everything in there, it’ll be useful later.

Copy the public key to Tencent cloud

First log in to Tencent cloud background, and then go to the cloud server management interface, click SSH key. Then click Create Key and select use your own public key.

Local SSH Settings

Import a public key authentication file

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

Modify the MAC configuration file

Host testHostname 192.168.11.11 Port 22 User root IdentityFile ~/. SSH /id_rsaCopy the code

Host you can set Hostname to the IP address of the CentOS Host Port and User you can set IdentityFile to the location of the private key file

Set up automatic passphrase

Ssh-add run the preceding command and enter the password you entered when you generated the key, so that you can log in directly in the future. Do not need to enter any password, directly use the key login.

SHH Key login method

SSH test: SSH test. Test is the Host name you set yourself.

Follow my wechat public number: ReactNative development circle