# SSH connection refused

> Fix an SSH connection that times out, is refused or denied: the IP rule of a Secure machine, the key, the user, and a changed host key.

Find your error below. The session page shows the exact SSH command once the session is **running**: start from it.

## `Connection timed out` on a Secure machine

A Secure machine accepts SSH on port 22 from one address: the public IPv4 address, or range up to a `/24`, entered at launch.

1. Check your public address: `curl -4 https://ifconfig.me`.
2. Compare it with the address on the session page.
3. Different? A VPN, a mobile hotspot or another network changed it. Connect from the address you entered, or end the session and launch a new one from your current address.

The address cannot change on a running session. Private ranges (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) are refused at launch: enter the public address.

## `Permission denied (publickey)`

The key your computer offers is not the key the machine holds.

- Connect as `ubuntu`, not `root`.
- Pass the private key explicitly: `ssh -i ~/.ssh/id_ed25519 ubuntu@<address>`.
- Check that the public key pasted at launch is the `.pub` file of that private key. See [SSH keys](https://nodelodge.com/docs/ssh-keys).

A running Secure session keeps the key it started with. To use another key, launch a new session.

## `Connection refused` right after launch

SSH is still starting inside the machine. Wait 30 seconds, then retry.

## `REMOTE HOST IDENTIFICATION HAS CHANGED`

A new machine reused an address you connected to before. Remove the old entry, then connect again:

```bash
ssh-keygen -R <address>
```

## Community sessions

A Community session needs no IP rule: connections reach your VM through Node Lodge. Use the command on the session page, or open JupyterLab from it. For `Permission denied (publickey)`, check the key as above.

## Still refused

Write to [support@nodelodge.com](mailto:support@nodelodge.com) with the session ID, the command you ran and the full error. Run `ssh -v` to get the details.
