All Documents
Current Document

Content is empty

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


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

Last updated:2021-08-04 11:26:07

Tools required: PuTTY and PuTTYgen

  1. Generate a key

Open the PuTTYgen tool, set 2048 in the lower right corner, and then click "Generate" to generate the key. The generation can be accelerated by moving the pointer left and right. After the key is generated, you can set the password for the key. Click "Save private key" to save the key. The public key must also be copied. It can be copied to a file first and then you can close this window, or this window may not be closed and you can copy the key when you use it.


  1. Upload the key generated to the KEC instance

Open putty, enter the KEC instance address, and then click "Open" to log in to the KEC instance with the user name and password (The CentOS account user name is root. When the password is entered, putty will not display it. Press "Enter" after you enter the password.)

Create an SSH key directory and SSH key file.

mkdir /root/.ssh (Create an SSH key directory)
touch /root/.ssh/authorized_keys (Create an SSH key file)

Edit the public key file and copy the public key.

vi /root/.ssh/authorized_keys

Press "I" on the keyboard to start editing, paste the public key copied, and press "Esc" to exit editing. Enter :wq to save and exit.

  1. Reconnect Enter the KEC instance address, click the "+" sign next to SSH on the left pane, click "Auth", and then select the key you just saved.

Click "Open" and then enter the key password.

  1. Configure the SSH service for the KEC instance Run the following command:
vim /etc/ssh/sshd_config

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

PasswordAuthentication no                    # Login with the password is not allowed.

The following figures show the modification.

Press Esc to exit the editing. Enter :wq to save and exit. Restart sshd.

systemctl restart sshd.service


The configuration has been completed, and you can only log in to the KEC instance with the key next time.

On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen