Skip to main content

HowTo: Connect to Linux instances using SSH with password

In addition to using the key pair as a credential for connecting to Linux instances using SSH, this document will show you how to use the account password to connect to the VCS Linux instance using SSH. This method prevents situations where the lost or the corruption of the key pair that makes connecting to the instance impossible, and is suitable for multiple users sharing instances.


Step 1. Add a user with password

  • Use key pair to connect to your VCS instance.
  • Execute the following command to add a user account (you can also add multiple users as needed), and then enter the password and related personal information.
sudo adduser <USER_ID>
caution

To protect the security of your VCS instance, please set the login password for Ubuntu or CentOS to contain at least 12 characters with a mix of upper and lower case letters, numbers, and special characters.


Step 2. Enable password authentication

  • Execute the following command to enable password authentication in sshd.
sudo sed -i '/^Include \/etc\/ssh\/sshd_config\.d\/\*\.conf/s/^/#/' /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication\ no/PasswordAuthentication\ yes/g' /etc/ssh/sshd_config
sudo sed -i 's/^#UsePAM no/UsePAM yes/' /etc/ssh/sshd_config

Step 3. Restart the sshd service

  • Execute the following command to restart the sshd service.

Ubuntu

sudo systemctl enable ssh.service
sudo systemctl restart sshd

Rocky

sudo systemctl restart sshd

CentOS

sudo systemctl restart sshd

Step 4. Check if you can connect to the instance with the account and password

  • Use MobaXterm as the connection tool, click SSH > enter Remote host IP > enter your user account > click OK

  • The following screen will be displayed, then enter the password you set to log in!