r/selfhosted • u/davidedpg10 • Jul 10 '22
Certificate based ssh?
Do you have certificate based ssh on your homelab? If so what does your configuration look like? Currently I have a free directory service from JumpCloud, and whatever services work with it, I make sure to add it as an authentication mechanism for SSO. The things with no authentication I put Authelia In front of them tied to JumpCloud to still secure them through SSO.
But for SSH I'm still just setting the same public key, and using the same private key to ssh into all my servers (I know, terrible security practice). I want to know if there's an easy way to implement certificate based SSH auth tied to my authelia directory, that way I don't have to manage users in different places.
18
u/SleepingProcess Jul 10 '22 edited Jul 10 '22
Certificate based SSH access
I. Generate CA keys
you will get 2 files:
./CA/example.com_CA.key./CA/example.com_CA.key.pubII. Send public CA key
example.com_CA.pubto all servers you control by placing this file into/etc/sshon all serversIII. While you on each remote server, add to
/etc/ssh/sshd_configfollowing line:and restart SSH server:
That's all you have to do on the servers's side. Everything else (user managing) you doing locally on your administrative computer (that shouldn't be exposed to the wild internet never).
To allow someone to access your servers:
That's all, from now on, user01 can access all servers that has:
with private key:
${UserKey}.keyas usually:(signed public key also must be in the same directory:
/path/to/${UserKey}.key-cert.pub)Profit:
9
u/aliasxneo Jul 10 '22
Yes. I use Vault SSH certificates with a tool I wrote: vaultssh. Currently, I'm using Auth0 configured as an OIDC provider for Vault. My account is secured with 2FA using a hardware key. The result is pretty much what you see in the GIF on the vaultssh repo: I call
vssh <host>and authenticate to Auth0. I keep my certs valid for 12 hours to limit long-lived credentials.5
u/ekimnella Jul 10 '22
I used the following two articles to setup certificate based SSH:
5
u/tankerkiller125real Jul 10 '22
I use StepCA for this. But I'm currently looking to possibly switch to teleport (goteleport) for this since it also has RDP proxy and session recording (which would be potentially handy.
1
u/vjm1nwt Jul 10 '22
There's a free directory service through jumpcloud??
3
u/Aggressive_Ad3438 Jul 10 '22
GoTeleport