The following is divided into two parts

First, Windows login example

MacOS /Linux login instance

First, Windows login example

How to obtain login information?

Login information in my example, the login command is:

ssh -p 60001 [email protected]

Enter the login host name, port number, and user name in the SSH client.

The host name* * * * port* * * * The user* * * *
i-1.gpushare.com 60001 root

Windows can use SSH clients such as Xshell, PuTTY, and MobaXterm for connection.

Xshell tutorial

Download (It is recommended to install Xftp at the same time for uploading and downloading data)

Xshell 7 (Free for Home/School)  

Xftp 7 (Free for Home/School)

Open the session window and create a session.

You can enter any name in the session attribute and retain the default SSH protocol. Host and port Number Enter the login information of the instance.

Switch to the username authentication TAB, fill in the username root, and copy the password in my example. Click OK to save.

Select the newly created session from the session and click Connect to enter the instance.

MacOS /Linux login instance

You can use the built-in terminal application in macOS/Linux.

MacOS can use iTerm2:

iTerm2

In my example, copy the login instructions and execute them on the terminal. When prompted, copy and paste the instance login password. The entered password will not be displayed on the terminal, and press Enter to log in.

Key landing

Using the key can realize password-free login and improve the security of server login authentication.

A key is a pair of files, divided into public and private keys. The private key is stored locally and the public key is stored in the instance. You first need to generate a pair of keys locally, and then add the public key to the platform. The public key is automatically added after the instance is created. You can use the private key to log in to the instance.

How to produce the generated key?

In Windows, you can use the key management function of the Xshell client to generate a key pair.

Select Tools – User Key Manager from the menu.

Select generate

The default configuration is used until the wizard is complete. You do not need to enter the key password.

Select the key you just added and click Properties.

Switch to the public key TAB to copy or save the entire public key as a file.

On macOS/Linux, the key pair is generated locally using the command line.

~# ls ~/.ssh/*.pub ~# ssh-keygen Generating public/private RSA key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa Your public key has been saved in /root/.ssh/id_rsa.pub The key fingerprint is: SHA256:m6kUxC7psGC0nNyj61DQMKBGKHwBsVILD4xfCi7NRx4 linux The key's randomart image is: +---[RSA 3072]----+ |%++.. | |[email protected]. | |*O== .o | |BoO o+ | |o*o+o o S | |.o.+.. . + | |... .. + | |.... | |. O. | + -- [SHA256] -- -- -- -- -- + # to check the public key content ~ # cat ~ /. SSH/id_rsa. PubCopy the code

Add the public key

Enter hengyuan Cloud console, enter instance and data – my instance, click SSH key to log in instance

Click on add

Fill in the remarks to add the previously generated public key content to the key.

The key is automatically added to the instance after the instance is created.

Login with key

Windows open the session window in Xshell, select the added session, and click Edit.

Select User authentication in the category. Check Public Key, move it up to the top, and hit Settings.

Select the user key you just generated and save the session after confirming it. After reconnecting to the session, you can log in to the instance using the private key.

MacOS /Linux directly SSH to the instance from the terminal, the default attempt to use the private key login.

To disable password login, enter the instance and run the following command. Before executing this command, ensure that the login succeeds. Otherwise, the instance may fail to be logged in.

sed -i "s/^#\? \(PasswordAuthentication\).*/\1 no/" /etc/ssh/sshd_config supervisorctl restart sshdCopy the code