SSH to a device without keys

Log in to a Linux device over SSH at its Peerlify address with your normal ssh client, no keys or passwords. Turn it on, write the rules, know the limits.

Updated · ·By Ivan Vyshniak

Nothing on this page changes with your selection.

Peerlify SSH lets you log in to a device in your network with your normal ssh client, without SSH keys or passwords. The device's Peerlify client answers on the device's Peerlify address, and it already knows which device is connecting, because the connection between two devices is encrypted and authenticated end to end. It lets you in only if the network's SSH rules say that device may log in as the account you asked for.

There are no keys to hand out, rotate or remove. Access follows the rules: change a rule, or remove a person or a device from the network, and the access is gone.

This is separate from running your own SSH server and reaching it over Peerlify, which works on any device and needs none of what is on this page. See Connect to a device.

Platforms

WindowsmacOSLinux
Connect with ssh✓✓✓
Be logged in to––✓

The device you log in to runs Linux with a current Peerlify client. The device you connect from needs nothing but Peerlify and an ssh client.

Three things have to be true before a login works:

  1. SSH is switched on on the device.
  2. An SSH rule lets your device log in to it as that account.
  3. The traffic rules let your device reach it on TCP port 22.

1. Switch it on on the device

On the device you want to log in to:

shell
peerlify ssh enable

From then on, port 22 on that device's Peerlify address is answered by Peerlify instead of the system's SSH server. The machine's other addresses are untouched: an SSH server already listening on its LAN or public address keeps working exactly as before.

To switch it off again, and to see whether it is on:

shell
peerlify ssh disable
peerlify ssh status

peerlify ssh status also shows the fingerprint of the device's host key (see Connect).

On the console's Devices page, a device with SSH switched on shows an SSH badge. The badge only says the device answers; who may log in is decided by the rules.

2. Write the rules

A new network has no SSH rules, so nobody can log in to anything until an admin adds one. Switching SSH on on a device grants no access by itself.

In the console, open Access → SSH and click Add SSH rule. Requires the Owner, Admin or Network admin role. A rule has three parts:

FieldMeaning
WhoThe devices that may connect, written like the source of any access rule: a group, a role, an email address, a tag, or * for every device. A person means the devices that person is signed in to.
DevicesThe devices they may log in to: a tag, a device, *, or The user's own devices.
Log in asThe accounts on the device they may log in as. These are the device's own Linux accounts, not Peerlify users: an account name such as ubuntu, autogroup:nonroot for any account except root, or * for any account, root included.

A login is allowed when at least one enabled rule matches all three: the connecting device, the device it connects to, and the account asked for. Click Save SSH rules; devices get the change within about 10 seconds.

Example: everyone reaches their own devices, never as root

Each person can log in to the devices they are signed in to themselves, as any account except root:

  1. Who: *
  2. Devices: turn on The user's own devices
  3. Log in as: autogroup:nonroot

The user's own devices compares owners: a login is allowed only when the same person is signed in to Peerlify on both devices. Tagged devices, such as shared servers, belong to no one, so this option never includes them, on either end.

Example: admins log in to the servers as root

Members of a group can log in as root to every device tagged servers:

  1. Who: group:admins
  2. Devices: tag:servers
  3. Log in as: root

The same two rules in the policy file, under Access → Advanced:

json
"ssh": [
  {
    "name": "Own devices",
    "source": ["*"],
    "destination": ["autogroup:self"],
    "users": ["autogroup:nonroot"]
  },
  {
    "name": "Admins to servers",
    "source": ["group:admins"],
    "destination": ["tag:servers"],
    "users": ["root"]
  }
]

A rule can be switched off without deleting it, with the switch in its row.

3. Connect

From any device the rules allow, use your usual client, the account you want, and the device's Peerlify address:

shell
ssh ubuntu@100.100.0.12

On Windows and macOS you can use the device's name instead:

shell
ssh ubuntu@build-server

You aren't asked for a key or a password. The first connection to a device shows ssh's usual question about an unknown host key. Compare the fingerprint it shows with the one peerlify ssh status prints on that device, then answer yes.

The account has to exist on the device and be able to log in (not an account whose shell is nologin). The device's IPv6 address works too.

The traffic rules apply too

SSH rules and traffic rules are both checked. An SSH rule decides who may log in as whom; it doesn't open the port. The traffic rules must also let the connecting device reach the other one on TCP port 22.

A new network's default traffic rule allows everything, so this needs attention only once you have replaced it. A rule like this one covers the second example above:

json
{
  "name": "Admins SSH to servers",
  "action": "accept",
  "source": ["group:admins"],
  "destination": ["tag:servers"],
  "ports": ["22"],
  "protocol": ["tcp"]
}

If you can't log in

Check the three conditions in order:

  1. SSH is switched on on the device. Run peerlify ssh status there, or look for the SSH badge on the console's Devices page.
  2. The traffic rules allow TCP port 22. From your device, peerlify acls --query=<device> shows whether a connection is possible.
  3. An SSH rule matches. On Access → SSH, the rule is enabled, your device is covered by Who, the other device by Devices, and the account you asked for is listed under Log in as.

Two cases come up often:

  • It works as ubuntu but not as root: the rule's Log in as is autogroup:nonroot, which excludes root.
  • The user's own devices doesn't let you in: you aren't signed in on both devices with the same account, or one of the two is tagged.

What is logged

  • Rule changes: every save of the policy is an Updated access controls entry in the audit log, with a diff, and a version under Access → History that you can compare and restore.

  • Connections: on Business and Enterprise plans, the connection to port 22 appears on Logs → Networking like any other connection between two devices, as reported by the connecting device. See Activity logs.

  • Logins, on the device itself: the Peerlify service on the device you log in to writes a line to its own log when a login is allowed (ssh.session.open, with the connecting device, the account and the rule that allowed it), when one is refused (ssh.session.denied, with the reason), when a command or shell starts, and when the connection closes. These lines stay on the device; they aren't sent to the console.

Peerlify doesn't record what is typed or shown in a session.

Limits

  • Linux devices only can be logged in to, for now. Windows and macOS devices can connect but not be connected to.
  • No port forwarding (-L, -R, -D), no agent forwarding (-A) and no X11 forwarding. Environment variables your client tries to send (SendEnv) are ignored.
  • File transfer with sftp and scp works when the device has an SFTP server installed (the openssh-sftp-server package on Debian and Ubuntu; it comes with openssh-server on most others).
  • The first connection asks about the host key, as with any SSH server. The device's fingerprint is shown by peerlify ssh status.
  • Error output of a non-interactive command arrives on standard output. With ssh host command, what the command writes to standard error is delivered together with its standard output, so 2> on your side separates nothing.
  • Nobody is allowed by default. A network has no SSH rules until an admin writes one.
  • Only Peerlify's own address is served. To reach the system's SSH server on that address again, switch Peerlify SSH off.

Next steps

Was this page helpful?