All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

How can I log in to a KEC instance through Xshell with a key?

Last updated:2020-06-11 15:16:20

  1. Generate a key.

Click the tool in the Xshell menu bar, select "New User Key Wizard", and execute the key pair generation operation.

Note: Set the key type to RSA and the key length to 2048, and then click Next.

Wait until the key is generated successfully, and then select Next. In the following window that appears, fill in the key name and the password for key verification.

Click Next to save the public key (the public key will be uploaded to the KEC instance).

The following figure shows the private key, which is used to log in to the KEC instance subsequently. The private key can be exported and saved.

Now the key is generated.

  1. Upload the key generated to the KEC instance. Click Create, and enter the address to connect to the KEC instance.

Click OK and then click Connect.

The CentOS user name is root.

Enter the password to complete the connection. Run the rz command (if there is no rz command, run yum install lrzsz and then enter y twice to confirm). After uploading the key file to the KEC instance, perform the following operations to add kectest.pub to /root/.ssh/.

ls -a 

mkdir .ssh
 chmod 700 .ssh/
 cd .ssh/
 cat ../kectest.pub > ./authorized_keys
 ls
chmod 600 authorized_keys

  1. Configure the SSH service for the KEC instance. Only the login with the key is allowed, and the login with the password is not allowed.
vim /etc/ssh/sshd_config

If there is no vim, run yum -y install vim to install it first. Press "I" on the keyboard to enter the edit operation, and perform the modification.

Modification:
PasswordAuthentication no                    # Login with the password is not allowed.

The following figures show the modification.

Press Esc to exit the edit mode, and then enter :wq to save and exit. Restart sshd

service sshd restart

service sshd restart

All configurations have been completed.

  1. Reconnection and login verification The following figure shows the process.

Password is displayed in grey and cannot be edited. Only the login with the key is allowed. In this case, select the key generated previously, and click OK to log in.

On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback