Login to the Linux instance¶
Windows login instance¶
Get login info¶
The login information is in the login instruction in My Instance, for example, the login instruction is:
ssh -p 60001 root@i-1.gpushare.com
The hostname, port number and user from which to extract the login need to be filled in the SSH client:
hostname | port | user |
---|---|---|
i-1.gpushare.com | 60001 | root |
Windows can connect using SSH clients such as Xshell, PuTTY, MobaXterm.
Xshell Tutorial¶
Download (recommended to install Xftp at the same time to facilitate uploading and downloading data):
Xshell 7 (Free for Home/School) Xftp 7 (Free for Home/School)
Open the session window to create a new session.
The name in the session attribute can be filled in arbitrarily, and the protocol remains the default SSH. Host, Port Number Fill in the login information of the instance.
Switch to the Username Authentication tab, fill in root for the username, and copy the password in My Instance. Click OK to save.
Select the newly created session in Session, and click Connect to enter the instance.
macOS/Linux login example¶
In the macOS/Linux system, you can use the terminal application that comes with the system.
macOS can use iTerm2:
Copy the login command in my instance and execute it in the terminal. When prompted to enter the password, copy the instance login password and paste it. Entering the password will not be displayed on the terminal. Press Enter to log in directly.
Secret login¶
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 a public key and a private key. The private key is stored locally, and the public key is placed in the instance. First you 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, and the private key can be used to log in directly to the instance locally.
Generate key¶
Under Windows, you can use the key management function that comes with the Xshell client to generate a key pair.
From the menu select Tools - User Key Manager.
Select Generate.
The default configuration is used in the wizard until completion, and the key password does not need to be filled in.
Select the key you just added and click Properties.
Switch to the Public Keys tab to copy or save the entire public key as a file.
Generate a key pair locally using the command line under macOS/Linux.
# Check whether the key has been generated locally, if so, it does not need to be generated
ls ~/.ssh/*.pub
# Generate a key pair, the input part of the file and passphrase prompts can be used directly by pressing Enter to use the default
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]----+
|%++.. |
|B@.oE. |
|*O== .o |
|BoO o+ |
|o*o+o o S |
|.o.+.. .+ |
|... . . + |
|. . . . |
|.o . |
+----[SHA256]-----+
# View the content of the public key
cat ~/.ssh/id_rsa.pub
Add public key¶
Enter Gpushare Cloud console, enter Instance and Data - My Instance, and click SSH key to log in to the instance.
Click Add.
Fill in the remarks and add the content of the previously generated public key to the key.
After the addition is complete, the key will be automatically added to the instance after the instance is created.
Login with key¶
Windows opens the session window in Xshell, select the added session, and click Edit.
Category select User Authentication. Check the Public Key check box, move it up to the top, and click Settings.
Select the user key you just generated, and save the session after confirming. After reconnecting to the session, you can use the private key to log in to the instance.
macOS/Linux directly logs in to the instance through ssh
in the terminal, and by default will try to log in with the private key.
warning
Even if the instance was created with a secret key, the instance still opens password authentication.
If you need to disable password login, you need to enter the instance and execute the following commands. Before execution, you need to confirm that the password-free key login is successful; otherwise, you may not be able to log in to the instance.
sed -i "s/^#\?\(PasswordAuthentication\).*/\1 no/" /etc/ssh/sshd_config
supervisorctl restart sshd