1. Help Center
  2. Virtual Machines
  3. Access and secure shell (SSH)

How do I enable SSH access to my virtual machine?

Enable incoming SSH traffic to your virtual machine

To enable incoming traffic to your virtual machine, you must create a security rule, this can be done using Hyperstack or the Infrahub API.

Hyperstack

To enable SSH access to your virtual machine in Hyperstack:

  1. Within Hyperstack, navigate to the Virtual Machines page.

  2. Click on the virtual machine for which you intend to enable SSH access.

  3. In the Security Rules section of the virtual machine, click the Enable SSH access button. This action will automatically generate a security rule allowing incoming traffic from any IP (0.0.0.0/0) on port 22 via the TCP protocol.

Incoming SSH traffic to this virtual machine will now be permitted.

Before

Enable SSH security rule before

After

Enable SSH security rule after

Infrahub API

Send a POST request to /core/virtual-machines/{virtual-machine-id}/sg-rules endpoint replacing virtual-machine-id in the path with the ID of the virtual machine for which you want to enable SSH access, and complete the body of the request as specified below.

  • Include the integer ID of the virtual machine that this security rule is being attached to in the path of the request as follows:
    /core/virtual-machines/{VM ID HERE}/sg-rules
  • Complete the request body with the following fields and values:

    Field Name Field Input Description
    remote_ip_prefix 0.0.0.0/0 Allows traffic from any source IP address.
    direction ingress Designates that the security rule is for incoming traffic.
    ethertype IPv4 Indicates the use of Internet Protocol version 4.
    protocol icmp Specifies the use of Internet Control Message Protocol.
    port_range_min 22 Specifies the minimum port value for SSH.
    port_range_max 22 Specifies the maximum port value for SSH.

Request

curl -X POST https://infrahub-api.nexgencloud.com/core/virtual-machines/{virtual-machine-id}/sg-rules \
-H "accept: application/json" \
-H "api_key: YOUR API KEY" \
-d '{
"remote_ip_prefix": "0.0.0.0/0",
"direction": "ingress",
"ethertype": "IPv4",
"protocol": "tcp",
"port_range_min": 22,
"port_range_max": 22
}'
NOTE

To authenticate Infrahub API requests, add an authorization header to your API request that contains an API Key as follows:

   -H "api_key: YOUR API KEY"

 

For further assistance, don't hesitate to reach out to us at:

Support Email: [email protected]

Sales Contact: [email protected]

Phone: +44 (0) 203 475 3402


nexgen logo

Please check out our Website and Social Media