Skip to main content

Secure Shell (SSH) Access

Secure Shell (SSH) is a network communication protocol that provides a secure way to access and manage remote resources. SSH is essential for accessing virtual machines (VMs) in Hyperstack. By using SSH, users can securely connect to their VMs, execute commands, and manage applications and services.

To gain SSH access to your VMs in Hyperstack, you must create an SSH key pair. A key pair consists of a private key, which you keep secure on your local machine, and a public key, which is stored in Hyperstack. When you attempt to connect to the VM, the SSH protocol uses these keys to establish a secure and authenticated connection, ensuring unauthorized users cannot gain access. For SSH access, a VM must have a public IP address assigned, as this allows the VM to be reachable over the internet, enabling remote management and connectivity.

Follow the steps outlined in this article to securely access your virtual machines.

In this article


Access your virtual machine via SSH

Prerequisites for SSH:

  • Verify your VM is running: On the 'My Virtual Machine' page in Hyperstack, ensure the VM is displaying an ACTIVE status. It may take some time for all services to initialize after the VM is deployed. If there is a connection error, retry after a few minutes.

  • Ensure your VM has a public IP address: To check if your VM has a public IP address, go to the 'Virtual Machines' section to open the 'My Virtual Machine' page.

    • If an IP address is listed under the 'Public IP' header, then your VM has a public IP.
    • If no IP address is listed, navigate to the 'Networking' tab on the VM's details page and toggle 'Public IP Attached' to assign one.
  1. Navigate to the 'Virtual Machines' section in Hyperstack and click on the VM name to see its details. Once the VM is ACTIVE, click on the 'Firewall' tab to access firewall settings for the virtual machine.

    Deploy VM 10

  2. Click the 'Enable SSH access' button.

    Deploy VM 11

    Enabling SSH access will automatically generate a firewall rule allowing incoming traffic from any IP (0.0.0.0/0) on port 22 via TCP, as illustrated below.

    Deploy VM 12

  3. To access your virtual machine via SSH, execute the following command in a terminal (such as Terminal, PowerShell, etc.):

    ssh -i [path_to_ssh_key] [os_username]@[vm_ip_address]
    • '[path_to_ssh_key]' is replaced with the path to the SSH key that was generated in the 'Create SSH key' step.
    • '[os_username]' is replaced with the username of the operating system running on your virtual machine.
      • For Windows, the username is Administrator
      • For Ubuntu, the username is ubuntu
      • For Centos, the username is centos
      • For Debian, the username is debian
      • For Fedora, the username is fedora
    • '[vm_ip_address]' is replaced with the IP address of your virtual machine, which you can find on the 'My Virtual Machines' page under the 'PUBLIC IP' column.

    For example:

    ssh -i ../_ssh_keys/example-key_hyperstack.txt [email protected]

Create an SSH key

Learn how to create an SSH key for connecting to your VM via Secure Shell (SSH) by following the steps below.

  1. Start by clicking the 'Create New SSH Key' button.

Deploy VM 6

  1. In the 'Generate an SSH Key' popup window, click the 'Generate SSH Key' tab (alternatively, import your own public key if you already have an SSH key).

  2. Complete the fields as shown below:
    a. Environment - Select the environment where the key will be created.
    b. Name - Give the key pair a name.

  3. Click 'Generate'

Deploy VM 7

tip

Save the location of your new SSH key, as you will need it to connect to your virtual machine.


Manually generate an SSH key pair

note

To automatically generate a key pair using Hyperstack's user-friendly UI, click here.

How to manually create a key pair:

  1. Open Terminal.

  2. Use the ssh-keygen command to create a new key:

    ssh-keygen
  3. After you run the command, you will be asked to specify the names of files where the keys will be saved and enter the password for the private key. Press Enter to use the default name. The key pair will be created in the ~/.ssh directory.

  4. Your public key will be saved with a .pub extension. The private key will be in the location you specified.

    Public key: /path/to/your/key.pub

    Private key: /path/to/your/key

  5. Copy the public key from the <key_name>.pub file using any text editor, such as Notepad. Please note that the key must be written as a single line (no returns or line breaks).

caution

Never share your private SSH key. Only the public key needs to be imported to access your virtual machines.


APIs for creating and managing SSH key pairs

To view the API reference documentation, click on the endpoint names below.

Endpoint NameURLDescription
List key pairsGET /core/keypairsReturns a list of your existing SSH key pairs.
Import key pair /core/keypairsImports an SSH key pair.
Update key pairPUT /core/keypair/{id}Modifies the name of an existing SSH key pair.
Delete key pairDELETE /core/keypair/{id}Deletes a key pair.

Back to top