Skip to main content

SSH to a node

This guide shows how to open an SSH session to a node with mctl. An organization owner, or an API key with the access "Pools: Full", logs in to the nodes of the organization's own pools. The owner can also let Multicloud support log in. See "Log in to a node of your pool" and "Support access".

Log in to a node of your pool

You need mctl, a sign-in (mctl auth login) and the role of organization owner. An API key with the access "Pools: Full" also works (console: Account, API keys; the API calls this scope org:admin). To store the key, run mctl auth login --api-key --org <org-id>. mctl asks for the key and hides what you paste. Do not paste a key into --key-stdin: the terminal shows it. That option is for scripts.

mctl ssh nodes [--pool <pool>]        # shows the node ids and public IPs of your pools
mctl ssh <node id or public IP>       # log in
mctl ssh <node> --pool <pool>         # look in one pool only

mctl does these steps:

  1. It finds the node in the pools of your organization.
  2. If your IPv4 address has no access, it asks: Open tcp/22 on <pool> for your IP for 1h? [Y/n]. Use --yes (-y) to skip the question. Without a terminal and without --yes, mctl exits with code 5.
  3. It opens tcp/22 for your address and waits until the port answers (up to 150 seconds).
  4. It makes a key for mctl in ~/.multicloud/ssh/ (once). It asks for a certificate for this key and runs ssh. The key is not in ~/.ssh. The private key never leaves your computer.

A certificate lasts 30 minutes. It works only from the IPv4 address that asked for it. mctl keeps the certificate and uses it again while more than 5 minutes remain. Then it asks for a new one. Put options for ssh after --: mctl ssh 12 -- -L 8080:localhost:80. A session that is open when the certificate ends stays open. A new login needs a new certificate.

If the login fails at once with exit code 255, mctl asks for a new certificate and tries one more time. It never repeats a remote command, so a command you give after -- runs at most one time. Your network address must be IPv4 (see "IPv4 only").

Support access

You can let Multicloud support log in to one pool of your organization for a limited time. Support cannot log in without your consent.

In the console: open the pool, then the Settings tab. In the Support access card, choose a time (1 hour, 4 hours, 1 day, 3 days or 7 days) and click Allow support access. For a shorter time, use mctl. The card shows the end time, who allowed it and how many support certificates were issued. If a consent is active, the button is Extend support access: the rules are the same as for allow below. Click Revoke to end it. A member who is not an organization owner sees a note and no controls: ask an organization owner.

With mctl:

mctl ssh support allow --pool <pool>              # 4 hours (default)
mctl ssh support allow --pool <pool> --for 24h    # longer, up to 7 days
mctl ssh support list                             # active consents and the certificates issued
mctl ssh support list --include-expired           # also the last 7 days
mctl ssh support revoke <consent id>
  • The default is 4 hours. The longest is 7 days (168h). The shortest is 5 minutes (5m).
  • Run allow again for the same pool to extend the consent. The consent can never last longer than 7 days after it was created. For more time, revoke it and allow again.
  • Support gets a certificate that lasts 30 minutes. A support certificate never outlasts the end time of the consent.
  • revoke stops new support certificates at once. A support certificate that support already holds stays valid until its own end, at most 30 minutes.
  • revoke does not close a network rule that an operator opened. The certificate is what stops the login.
  • mctl ssh support list shows each consent (ID, ORG, POOL, CREATED_BY, EXPIRES_AT, STATE) and CERTS, the number of certificates issued under it. Use --json to see who got each certificate and when. The certificate issue log is deleted with the pool (ON DELETE CASCADE), so a deleted pool keeps no login history in Multicloud.
  • An operator with no --org, no MULTICLOUD_ORG and no --include-expired sees the active consents of all organizations. With one of them, mctl asks for one organization, and the operator must be an owner of that organization. Otherwise the command fails (exit code 3).
  • Only an organization owner of the pool can allow support. Another organization gets 404.

How it works

Port tcp/22 is closed on every node by default. A grant opens tcp/22 for one IPv4 address. The address is yours. The API takes the address from your connection. You cannot name another address. The scheduler leader applies each grant to the cloud firewalls. It does this on a 60-second tick. The port opens up to about 2 minutes after you create a grant. The scheduler writes the address into the cloud firewall of the cluster: the AWS security group, the Azure NSG or the Google Cloud firewall rule. The firewall rule ends when the grant expires or when you revoke it.

Before you start

  1. Install mctl and sign in with your browser: mctl auth login.
  2. Check that your computer has an IPv4 route to the Internet (see "IPv4 only").

Steps

1. List the nodes

mctl node list
mctl node list --cluster <id or slug>

The table shows the node id, the cluster, the provider, the region, the public IP and the status.

2. Connect

mctl ssh <node id or public IP>

mctl does these steps:

  1. It reads your IPv4 address and your active grants.
  2. If you have no grant, it asks: Open tcp/22 for <ip> for 1h? [Y/n]. Press Enter to accept.
  3. It waits until tcp/22 answers. It tries every 5 seconds, for up to 150 seconds.
  4. It starts ssh <user>@<ip>. The user is multicloud unless the node names another user.

Use --yes (-y) to skip the question. Without a terminal and without --yes, mctl exits with code 5. It prints the mctl ssh allow command to run. Put options for ssh after --:

mctl ssh 12 -- -L 8080:localhost:80

3. Open access before you connect (optional)

mctl ssh allow                      # all platform clusters, 1 hour
mctl ssh allow --for 4h             # 4 hours
mctl ssh allow --cluster <id>       # one cluster

The command prints the grant id, the address (a.b.c.d/32) and the expiry time. Run the command again to extend your grant.

4. List and revoke grants

mctl ssh list                       # active grants of all people
mctl ssh list --include-expired     # also the last 7 days
mctl ssh revoke <grant id>

Revoke your grant when you finish. The firewall rule ends within about 2 minutes.

Expiry

Item Value
Default duration 1 hour
Shortest duration 5 minutes
Longest duration 8 hours
Automatic extension mctl ssh NODE extends your grant when 30 minutes or less remain
Maximum active grants 5 for each person

IPv4 only

api.multicloud.io has IPv4 and IPv6 addresses. The API opens the firewall for the address it sees on your connection. SSH to the nodes uses IPv4. An IPv6 address would open a rule that SSH never uses. For this reason, mctl sends every grant call over IPv4. If your computer has no IPv4 route, the API answers 400 (SSH grants need an IPv4 source).

Platform clusters and customer pools

A grant without --cluster reaches the platform clusters only. A grant with --cluster <id> reaches that cluster. The cluster can be a platform cluster or a customer pool. Login to a node of a customer pool always uses a certificate. An operator needs an active support consent of the customer (see "Support access"). Without it, mctl prints: No active support consent for pool <pool>. Ask the organization owner to run: mctl ssh support allow --pool <id>. Platform nodes keep the platform key.

Troubleshooting

Symptom Cause Action
HTTP 403, exit code 3 You do not have the role multicloud-admins, or you are not signed in. Ask an administrator for the role. Run mctl auth login again.
HTTP 400 SSH grants need an IPv4 source The API sees an IPv6 address or no IPv4 address. Use a network with IPv4. Check the address (see below).
HTTP 429 You have 5 active grants. Run mctl ssh list. Revoke a grant with mctl ssh revoke <id>.
waiting for the firewall rule (grant N), then exit code 5 The scheduler has not yet applied the grant. Wait 2 minutes. Run the command again.
No node ..., exit code 4 The node id or IP is wrong. Operator: run mctl node list. Customer: run mctl ssh nodes.
ssh failed (exit 255) The certificate ended, or the network failed. Run the command again to get a new certificate.
HTTP 404 on ssh support or on certificates The feature is not on for your environment yet. Ask Multicloud support.
The node has no public IP The node is still starting. Wait. Run mctl node list.

The grant must match the address that the node sees. Compare the address of the API with the address of a third party:

curl -4 https://checkip.amazonaws.com

Then compare it with GET /api/v1/ssh-access/source. The value of source must be the same. If the two addresses differ, a proxy or a VPN changes your address. Use a network without the proxy. If the port stays closed after 2 minutes, contact Multicloud support.