Connecting to a VM's serial console via CLI
After enabling access, you can connect to the serial console to interact with the VM.
Warning
When assessing the risk of enabling access via the serial console, consider the following:
-
The VM can still be managed from the internet even if there is no external IP address.
To access the VM serial console from the Yandex Cloud management console, a user must be authenticated in the Yandex Cloud management console and have the proper permissions to the VM. One can access the VM serial console from an SSH client application, such as PuTTY, or the YC CLI via SSH key authentication. To reduce the risk of web session hijacking, you should closely monitor your SSH key and make sure you terminate the web session. -
The session will be simultaneously shared by all users who have access to the serial console.
Users will be able to see each other's actions if concurrently watching the serial console's output. -
A valid session can be exploited by another user.
We recommend using the serial console only when absolutely necessary, grant access to a narrow group of people, and use strong VM passwords.
Make sure you disable access after you finish using the serial console.
Connecting to the serial console
Note
How the serial console works depends on the operating system settings. Compute Cloud provides a communication channel between the user and COM port on the VM, but it does not guarantee that the console works properly on the OS.
To connect to the serial console, use the CLI.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View the description of the CLI command for connecting to the serial console:
yc compute connect-to-serial-port --help
-
Get a list of VMs in the default folder:
yc compute instance list
Result:
+----------------------+-----------------+---------------+---------+----------------------+ | ID | NAME | ZONE ID | STATUS | DESCRIPTION | +----------------------+-----------------+---------------+---------+----------------------+ | fhm0b28lgfp4******** | first-instance | ru-central1-a | RUNNING | my first vm via CLI | | fhm9gk85nj7g******** | second-instance | ru-central1-a | RUNNING | my second vm via CLI | +----------------------+-----------------+---------------+---------+----------------------+
-
Select the
ID
orNAME
of the VM, e.g.,first-instance
. -
Connect to the Linux serial console:
yc compute connect-to-serial-port \ --instance-name first-instance \ --ssh-key ~/.ssh/id_ed25519
Or to Windows SAC:
yc compute connect-to-serial-port \ --instance-name first-instance \ --port 2
Where:
-
--instance-name
: Required parameter. VM name. -
--user
: Optional parameter. Username. If this parameter is omitted, the defaultyc-user
user will be used. Theyc-user
user is created automatically when creating the VM. For more information, see Creating a VM from a public Linux image. -
--port
: Optional parameter. Port number to connect to the serial console.- The default value is 1. You do not need to specify this parameter to connect to the Linux serial console.
- When connecting to the Windows serial console (SAC), specify 2.
-
--ssh-key
: Optional parameter. Path to the private key for SSH access to the Linux VM to be added to the metadata. If this parameter is omitted, theyc_serialssh_key
SSH key is generated.Alert
You can only connect to a VM's serial console via SSH using a non-password-protected key. Otherwise, the connection will be terminated after you enter a password.
-
Troubleshooting
- If you connect to the serial console and nothing appears on the screen:
- Press Enter.
- Restart the VM (for VMs created before February 22, 2019).
- If the OS requests user credentials to provide access to the VM, enter the username (login) and password:
- On a Linux VM, set a user password first. Run the
sudo passwd <username>
command. For more information, see Getting started with the serial console. - On a Windows VM, enter your username, domain (VM name), and password. For more information, see Starting your terminal in the Windows serial console (SAC).
- On a Linux VM, set a user password first. Run the
Disconnecting from the serial console
To disconnect from the serial console:
- Press Enter.
- Enter the following characters in order:
~.
.