How to use a key pair to log on to a Linux instance depends on the local operating system.
|You can use a password to connect to a Linux instance. For more information, see Connect to a Linux instance by using a password and Connect to an instance by using the Management Terminal.|
In this section, it is demonstrated how to use a key pair to log on to a Linux instance on a Windows system, using the popular SSH tools PuTTY and PuTTYgen as an example.
PuTTY and PuTTYgen must have been installed. You can download them at:
You must have a Linux instance that has been bound to an instance. You can allocate an SSH key pair when creating an instance or bind an SSH key pair to an instance.
- Add the following rule in the security group to enable the access to the TCP Port 22 of the instance. For more information, see Add security group rules.
Network Type NIC Rule Direction Authorization Policy Protocol Type Port Range Authorization Type Authorization Object Priority VPC N/A Inbound Allow SSH(22) 22/22 Address Field Access 0.0.0.0/0 1 Classic Internet
- Optional. If you are using a key pair generated by Alibaba Cloud, of which the private key is a .pem file, you must convert it to a .ppk file. If your private key is a .ppk file, you can skip this step.
Note When you create an SSH key pair, download the .pem private key.
- Start PuTTYgen. In this example, we use PuTTYgen version 0.68.
- Under RSA.
Note The value of Number of bits in a generated key can be left as is. The software automatically update the value based on the imported private key information.
- Click Load to find your .pem file.
Note By default, PuTTYgen only displays files with an extension of .ppk.
- Select the downloaded private key file from Alibaba Cloud, or the ready private key file, and click Open.
- Click OK to close the confirmation dialog box.
- Click Save private key. PuTTYgen displays warning about saving the key without a password. Click Yes.
- Specify the same name for the private key with the key pair, and save the settings. PuTTY automatically adds the .ppk file.
- Start PuTTY.
- Select Browse… and select the .ppk file generated in Step 1.
- Click Session.
- In Host Name (or IP address), enter your account and the public IP address of the instance to be connected to. The format is root@IP address.
- In Port enter the port number 22.
For Connection type, select SSH.
- Click Open to start accessing your Linux instance.
When the window shows
Connection established., it indicates you have successfully logged on to the instance using the key pair.
Linux OS or other systems supporting SSH commands
In this section, it is demonstrated how to use a key pair to log on to a Linux instance on a Linux system or a system supporting SSH commands, such as MobaXterm for Windows.
You must have a Linux instance that has been bound to an SSH key pair. You can allocate an SSH key pair when creating an instance , or bind an SSH key pair to an instance.
Add the following rule in the security group to enable the access to the TCP Port 22 of the instance. For more information, see Add security group rules.
|Network Type||NIC||Rule Direction||Authorization Policy||Protocol Type||Port Range||Authorization Type||Authorization Object||Priority|
|VPC||N/A||Inbound||Allow||SSH(22)||22/22||Address Field Access||0.0.0.0/0||1|
- Locate directory of your private key, for example, /root/xxx.pem.
Note When you create an SSH key pair, download the .pem private key. xxx.pem is the private key file.
- To modify the attributes of the private key, run the command:
chmod 400 [directory of the private key file]. For example,
chmod 400 /root/xxx.pem.
- To connect to the instance, run the command
ssh -i directory of the private key file] root@Internet IP address. For example,
ssh -i /root/xxx.pem email@example.com.