KoskenDocs Open the app

Machines with no agent: SSH and AWS SSM

Reach a machine over SSH or AWS SSM from a reach host in your network, confirm its host key, and choose the path of an order.

5 min readUpdated on Español

On this page
  1. How it works
  2. Set up SSH or SSM for a machine
  3. The fields
  4. Machines that the reach host finds
  5. Host keys
  6. Ways to run an order
  7. Stop reaching a machine
  8. Commands on the reach host

This guide shows how Kosken reaches a machine over SSH or AWS SSM through a reach host, how to confirm a host key, and how to choose the path of an order.

How it works

A reach host is a Linux host in your network that runs a small program, kosken-connector. It keeps the SSH keys and the AWS access. It connects out to Kosken and opens no inbound port. It gets the same signed orders as an agent and checks each order on its own before it runs it. See the whitepaper.

Kosken never stores a key or a passphrase. It keeps only settings that are not secret, such as the user, the port and file paths.

You can use a reach host in two ways:

  • A machine with no agent. Kosken reaches it only over SSH or SSM. The reach host checks every 30 seconds that the machine answers, and reads its load, memory, disk and failed units. Monitors do not run on such a machine.
  • One more path to a machine with an agent. The agent stays the main path. SSH or SSM give a second way to run an order.

Set up SSH or SSM for a machine

You need write access.

  1. Open the machine and select the tab Access.
  2. In How Kosken reaches this machine, check SSH, SSM or both.
  3. Open Advanced settings and fill the fields (see The fields).
  4. Select Save. The card shows Entry for targets.yaml.
  5. Select Make the install command. Copy the command. Kosken shows the key one time.
  6. On the reach host, run the command as root. It installs kosken-connector as a systemd unit.
  7. Select Copy under Entry for targets.yaml, and add the entry to /etc/kosken-connector/targets.yaml on the reach host.
  8. For SSH with no Key file: copy the line under Key of the reach host into ~/.ssh/authorized_keys of the SSH user on the machine.
  9. Tell the reach host to read the file again. The command checks the file first and prints the reason of an error:
    sudo /usr/local/lib/kosken/current/kosken-connector reload

One reach host can reach many machines. For the next machine, add its entry to the same targets.yaml and reload. Each Make the install command makes a new reach host.

The dialog Connect machine has the same choices for a new machine. It always starts with the agent, so the new machine shows Pending until an agent connects. For a machine that will have no agent, see Machines that the reach host finds.

The fields

Address, Port, User
Where the reach host connects over SSH. An empty port means 22.
Key file, Passphrase file
Paths under secrets/ on the reach host, for example secrets/web-01.key. An empty key file means the key of the reach host. Never paste a private key.
Host key pin
Optional, in the form SHA256: and the fingerprint. With a pin, you do not confirm the key on the first connection.
Run with sudo
Steps that need root run with sudo. The user must have sudo with no password.
Users an order may ask for, Allow sudo by order
Let an order run as another user, or ask for sudo. Empty means an order cannot change the user.
Use Ansible
Adds ansible: true to the entry. Only for a reach host that has Ansible.
Instance ID, Region, AWS profile
The EC2 instance for SSM, for example i-0a12b3c4d5e6f7890 in eu-west-1. The profile is optional. The AWS access of the reach host needs ssm:SendCommand, ssm:GetCommandInvocation and ec2:DescribeInstances.

The directory /etc/kosken-connector/secrets/ must have the mode 700, and each key file the mode 600. The reach host refuses to load the targets otherwise.

Machines that the reach host finds

After a reload, the reach host tells Kosken the name and the method of each entry. Nothing else leaves the host. On Machines, the card Ready to connect lists each entry that is not in use yet:

  • Confirm host key: shows when the SSH key of the machine waits for you. Compare the fingerprint, then confirm.
  • Bind to a machine: makes the entry one more path to a machine that has an agent. Choose the machine and select Bind to a machine.
  • Start managing: adds a new machine with no agent. Fill Name, Environment and Roles. The machine uses one slot of your plan.

Two machines cannot have the same name. If a pending machine has the name that you want, delete it first, or choose another name.

A row Waiting for the first report from means the reach host is not installed yet. Cancel removes it.

Host keys

On the first SSH connection, the reach host keeps the host key of the machine and waits. No order runs until you confirm it. Select Confirm host key on Ready to connect, or on the tab Access of a machine with no agent. You can also confirm it on the reach host. The command shows the fingerprint and asks you to type yes:

sudo /usr/local/lib/kosken/current/kosken-connector trust web-01

If the host key changes later, the reach host stops all orders to that machine, and the path shows Host key changed. Find out why the key changed before you confirm the new one.

Ways to run an order

The tab Access lists each path and its state:

  • Agent: Online or Offline.
  • SSH and SSM: Not selected, No target bound yet, Ready, Reachable, Unreachable, Host key waits for your confirmation or Host key changed.

Select Test path on a path that is available (write access). Kosken runs a read-only recipe through it and shows The path test passed. or The path test failed.

The agent is the default path. On the approval page, Run through lists the paths that are available. Approvals from a chat always use the agent. See Approvals.

Stop reaching a machine

On the tab Access of a machine with no agent:

  • Stop managing archives the machine. The entry goes back to Ready to connect.
  • Revoke access revokes the reach host. This machine, and every machine that the same reach host reaches, are archived.

Commands on the reach host

The program is /usr/local/lib/kosken/current/kosken-connector. Run it with sudo:

status
The connection, the certificate and each entry with the state of its host key.
doctor
Checks DNS, targets.yaml, the file modes, and that each machine answers.
reload
Checks targets.yaml and reads it again. A bad file keeps the previous good one.
trust and a name
Shows a waiting host key and confirms it.
uninstall
Removes the unit, /usr/local/lib/kosken, /etc/kosken-connector with the keys in secrets/, and the state. If the same host runs an agent, this also removes the agent program.

The unit is kosken-connector. Read its log with journalctl -u kosken-connector.

Something here does not match the app? Tell us