SSH connections using a login and password are disabled by default on public Linux images that are provided by G-Core Labs.
Connecting with a key pair — when the public part of the key is located on the virtual machine, and the private key is stored by the user — is more secure, therefore we recommend this method.
Check the firewall settings: to connect via SSH, the firewall must have an appropriate rule configured for the incoming traffic.
Creating an SSH key pair
To generate keys on Linux/MacOS/Windows 10:
- Open the terminal (for Windows 10 this is cmd.exe, or powershell.exe).
- Run the command:
$ ssh-keygen -t rsa-b 2048
After the command runs, you will be asked to specify the names of files where the keys will be saved and enter the password for the private key. The default name is id_rsa, keys are created in the ~directory./ ssh (for Linux/MacOS) or in C:\Users\<username>\.ssh\ (for Windows 10).
The public part of the key will be stored in a file with the name <keyname>.pub. Insert this part of the key into the "SSH key content" field when you create a new virtual machine through the management console.
If you are using Windows 7/8, use PuTTY — PUTTYgen — to generate keys.
Connecting to virtual machine
After the virtual machine has reached the "Power on" status, you can connect to it via SSH. Use the ssh client on Linux/macOS/Windows 10 or PuTTY on Windows 7/8.
To connect, you will need to specify:
- user name
If you use one of the public images to create a virtual machine, the user name is often the same as the image name. Exceptions: coreos is the core OS username and rancheros is the rancher OS username.
When you select an image in your personal account, a hint appears:
- the public address of the virtual machine. If you created a machine only with an internal IP address, go to its settings and add a floating IP: "Instances" → "Overview" → "Add IP". You will be redirected to the "Floating IPs" section, which is described in more detail in the article "Networks, Subnetworks, Floating IPs, Firewalls".
Internal IP addresses can be used to establish SSH connections between virtual machines within the same cloud network.
Connecting with SSH client
Run the following command in the terminal:
$ ssh <username>@ <virtual_machine_floating_IP_address>
If you are connected to the machine for the first time, you may receive a warning about an unknown host:
The authenticity of host '220.127.116.11 (18.104.22.168)' can't be established.
ECDSA key fingerprint is SHA256:cw4aYWnWUbOUwEceRh04ImJZ7I7DVVOtIeZZGaGZ39I.
Are you sure you want to continue connecting (yes/no)?
In the terminal, type Yes and press Enter.
If you have difficulties connecting via SSH you can look through the "SSH connection issues and troubleshooting" article where we describe the most common issues and the ways to solve them.