This topic describes how to connect to a Linux server by using the Simple Application Server console or by using a third-party client.
Background information
You can use the Simple Application Server console to connect to a server. For more information, see (Recommended) Connect to a Linux server by using Workbench in the Simple Application Server console.
Note that if key-based logon is enabled on a Linux server, password-based logon is automatically disabled for the root
account on the server. To re-enable password-based logon, you must modify the configuration file. For more information, see Re-enable password-based logon.
(Recommended) Connect to a Linux server by using Workbench in the Simple Application Server console
- Connect a server with one click on Workbench: You can connect to the server as the
admin
user without entering a username and password. In this case, some features such as file processing that require root user permissions cannot be used. - Connect a server as a root user on Workbench: You can connect to the server as a
root
user. You need to enter a password.
- Log on to the Simple Application Server console.
- In the left-side navigation pane, click Servers.
- Use one of the following methods to connect to your Linux server: In this example, the method of connecting a server with one click on Workbench is used.
- On the Servers page, move the pointer over the
icon in the server card and click Connect with One-click on Workbench.
- On the Servers page, click the card of the server to which you want to connect. In the upper-right corner of the Overview page, choose .
- On the Servers page, click the card of the server to which you want to connect to go to the Overview page. In the left-side navigation pane, choose . On the Client tab, choose .
root
user to connect to the server. - On the Servers page, move the pointer over the
- Optional: Use Workbench to manage files in the Linux server If you connect to the Linux server as a root user, Workbench provides a GUI to allow you to manage files in the Linux server. You can use Workbench to view, add, delete, and modify files in the Linux server. You can also use Workbench to upload and download files in the Linux server. For more information, see Manage files.
Connect to a Linux server from a Windows device
Method 1: Connect to a Linux server by using the system account and password
This method is applicable to Linux servers with a configured logon password. For more information, see Manage the password of a server.
- Download and install PuTTY on your Windows device. To download PuTTY, see PuTTY: a free SSH and Telnet client.
- Start PuTTY.
- Configure the Linux server to which you want to connect. Configure the following parameters:
- Host Name(or IP address): Enter the public IP address of the Linux server. Example:
121.40.XX.XX
. - Port. Enter 22.
- Connection type: Select SSH.
- Optional:Saved Sessions: Enter a name that is easy to identify and click Save to save the session. The next time you log on to the server, the saved session information such as the public IP address is automatically entered.
- Host Name(or IP address): Enter the public IP address of the Linux server. Example:
- Click Open. The first time you connect to the instance, the PuTTY Security Alert message appears. This message indicates that PuTTY cannot verify the authenticity of the remote server (instance) and can provide only the public key fingerprint of the server instead. Click Yes to indicate that you trust this server. PuTTY then adds the public key fingerprint to the registry of your device.Note If the PuTTY Security Alert message appears the next time you connect to the instance, the instance may have suffered from man-in-the-middle attacks. For more information, see PuTTY User Manual.
- On the command line, enter
root
, which is the system account of the Linux server. Then, press the Enter key. - On the command line, enter the logon password that corresponds to the root account of the Linux server and press the Enter key. Note When you enter a password, no command output is returned to maximize data security. You need only to enter the correct password and then press the Enter key.A welcome page similar to the following figure indicates that you are logged on to the server.
Method 2: Connect to a Linux server by using a key pair
This method is applicable to Linux servers with a bound key pair. For more information, see Create a key pair.
- Convert the format of a private key file. If the key file bound to your Linux server is automatically generated by Alibaba Cloud in the .pem format, you must convert the key file from the .pem format to the .ppk format before you can use PuTTY to connect to the server. Perform the following operations:
- Download and install PuTTY on your Windows device. To download PuTTY, see PuTTY: a free SSH and Telnet client.
- Start PuTTY.
- Configure the Linux server to which you want to connect. Configure the following parameters:
- Host Name(or IP address): Enter the public IP address of the Linux server. Example:
121.40.XX.XX
. - Port. Enter 22.
- Connection type: Select SSH.
- Optional:Saved Sessions: Enter a name that is easy to identify and click Save to save the session. The next time you log on to the server, the saved session information such as the public IP address is automatically entered.
- Host Name(or IP address): Enter the public IP address of the Linux server. Example:
- In the left-side navigation pane, choose .
- In the Authentication parameters section, click Browse...
- Select the key file in the .ppk format on your local device, and then click Open.
- Click Open. The first time you connect to the instance, the PuTTY Security Alert message appears. This message indicates that PuTTY cannot verify the authenticity of the remote server (instance) and can provide only the public key fingerprint of the server instead. Click Yes to indicate that you trust this server. PuTTY then adds the public key fingerprint to the registry of your device.Note If the PuTTY Security Alert message appears the next time you connect to the instance, the instance may have suffered from man-in-the-middle attacks. For more information, see PuTTY User Manual.
- On the command line, enter
root
, which is the system account of the Linux server. Then, press the Enter key.A welcome page similar to the following figure indicates that you are logged on to the server.
Connect to a Linux server from a Linux or macOS device
- Method 1: Connect to a Linux server by using the system account and password
This method is applicable to Linux servers with a configured logon password. For more information, see Manage the password of a server.
- Run the following command to connect to a Linux server:
Sample command:ssh root@<public IP address of the Linux server>
ssh root@121.40.XX.XX
- Enter
yes
and press the Enter key.The first time you connect to the Linux server, the system cannot independently verify the authenticity of the server. The system instead provides you with the public key fingerprint of the server and asks you to confirm whether to continue with the connection. Enter
yes
to indicate that you trust the server. - Enter the logon password that corresponds to the root account of the Linux server and press the Enter key. Note When you enter a password, no command output is returned to maximize data security. You need only to enter the correct password and then press the Enter key.
- Run the following command to connect to a Linux server:
- Method 2: Connect to a Linux server by using a key pair
This method is applicable to Linux servers with a bound key pair. For information about how to create a key pair for a server, see Create a key pair.
- Find the private key file stored on your local device.
In this example, /test/XXX.pem key file is used.
- Run the following command to modify permissions on the private key file.
Replace /test/XXX.pem with the actual path of the private key file.
chmod 400 /test/XXX.pem
- Run the following command to connect to the Linux server.
Replace <public IP address of the Linux server> and /test/XXX.pem with the actual public IP address of the Linux server and the actual path of the private key file.
ssh root@<public IP address of the Linux server> -i /test/XXX.pem
- Find the private key file stored on your local device.
Re-enable password-based logon
After you create a key pair for a simple application server and restart the server for the new key pair to take effect, password-based logon is automatically disabled for the root
account on the server. To re-enable password-based logon, you must modify the configuration file of the server. Perform the following operations:
- Connect to the server by using the Simple Application Server console. For more information, see (Recommended) Connect to a Linux server by using Workbench in the Simple Application Server console.
- Run the following command to open the /etc/ssh/sshd_config file:
vi /etc/ssh/sshd_config
- Press the I key to enter the edit mode. At the end of the file, change
PasswordAuthentication no
toPasswordAuthentication yes
.The following figure shows the modified configurations. - Press the Esc key to exit the edit mode. Then, enter
:wq
and press the Enter key to save and close the file. - Run the following command to restart the SSH service:
sudo service sshd restart
After SSH is restarted, you can use theroot
account and its password to connect to the Linux server. If you have not set a password or forgotten the password of the server, set or reset the password. For more information, see Manage the password of a server.Important When you use a password to connect to the server, make sure that the entered password is correct.
FAQ
For more information about solutions to problems such as timeout or failure that occur when you connect a server, see FAQ. If the issue persists, you can submit a ticket to contact technical support.