SSH Jump Server once again

The previously presented idea of the jump server was ok, but it doesn’t scale well. The poor scaling is due to passing your public key somewhere like the git repository and around this repo you build your automation like ansible. What about a more self-support solution and a more “enterprise” one.

Now comes with help Vault - a tool that can manages your secrets. It contains a concept of secret engines a kind of plugin that extends vault. One of the plugins is SSH which lets you sign your SSH public key with CA and the SSH server can be instructed to authorize your public key with CA public key. Whenever you sign your public key you can pick extensions to it, so ie. you can sign a key that is only allowed to setup port-forwarding and nothing else. It’s not a vault feature but openssh one. Unfortunately, it’s not feature-rich as in “authorized_keys” file ie. lacks permitopen option (but can be applied later phase), the full list of options is here.

So how it can look like from a 1000-foot view:

It’s already been written here how to setup things up, so don’t want to copy and paste, but I will mention a few steps:

$ vault write ssh-client-signer/roles/my-role -<<"EOH"
{
  "algorithm_signer": "rsa-sha2-256",
  "allow_user_certificates": true,
  "allowed_users": "ubuntu",
  "allowed_extensions": "",
  "default_extensions": {
    "no-user-rc": "",
    "no-pty": "",
    "permit-port-forwarding": ""
  },
  "key_type": "ca",
  "default_user": "ubuntu",
  "ttl": "30m0s"
}
$ vault write -field=signed_key ssh-client-signer/sign/my-role -<<"EOH"
{
  "public_key": "<pubkey>",
  "valid_principals": "ubuntu",
  "extensions": {
    "permit-pty": ""
  }
}
EOH
...
* extensions [permit-pty] are not on allowed list
$ cat /etc/ssh/auth_principals/ubuntu
permitopen="1.2.3.4:22" ubuntu
$ cat ~/.ssh/config
...
Match host <host> exec "~/sign-key.sh > ~/.ssh/signed.pem"
    HostName <hostname>
    User ubuntu
    IdentityFile ~/.ssh/id_ed25519
    IdentityFile ~/.ssh/signed.pem
...

To sum up vault or probably any other around signing ssh public keys can significantly scale up your solution even to some point that you can omit using some identity management solutions like FreeIPA.

comments powered by Disqus

powered by Hugo and Noteworthy theme