I moved over to certificates a while ago.
Selfhosted
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.
Rules:
-
Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.
-
No spam posting.
-
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.
-
Don't duplicate the full text of your blog or github here. Just post the link for folks to click.
-
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
-
No trolling.
-
No low-effort posts. This is subjective and will largely be determined by the community member reports.
Resources:
- selfh.st Newsletter and index of selfhosted software and apps
- awesome-selfhosted software
- awesome-sysadmin resources
- Self-Hosted Podcast from Jupiter Broadcasting
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
That's a really interesting read, thanks for sharing
So what happens when the certificate expires? Do you get locked out if you don't have physical access?
Re-gen the keys. In this environment, you would have PKI setup and automation to handle cert renewal.
Having the certs expire is an advantage, security-wise. Auth will expire with certs, stolen creds can be instantly invalidated.
Trategie is vulnerable and deprecated. You might want to try its secure successor Strategie
The best way is to use ssh-ca and certificate based auth.
Ssh-ca is amazing, built my own with small step ca
The general process would look something like:
- Find all of the SSH keys you want to replace.
- For each of thise keys, identify everywhere you use it to authenticate, and write this down! This list will form the basis of the rest of the plan. Make sure you list all of the accounts/servers you log in to, and don't forget things like github or other external systems if you use them.
You'll need to perform the following steps for each SSH key you are replacing:
- Rename the public and private keys to something like
old_id_rsaandold_id_rsa.pub(obviously use the same type name as your key, just prefixold_) - In your
~/.ssh/config, add a line telling SSH to use the old key as well as the new ones:IdentityFile ~/.ssh/old_id_rsa(change the key filename as aporopriate) - Check you can still log in to the servers you could log in to before. It should still be using the old key, just with a different filename, so it should still work.
- Generate your new SSH keys
ssh-keygen -t ed25519 - Log in to each server and ADD the new
~/.ssh/id_ed25519.pubkey to theauthorized_keysfile or equivalent mechanism. Do not remove the old public key yet. - Remove the
IdentityFileline from your~/.ssh/config - Check you can log in to all your systems. This will validate that your new key is working.
- Remove your old public key from the
authorized_keysfile on each server you log in to.
Depending on your threat model you're going to want to do this more or less often, and so you may want to consider automating it with sonething like ansible if it'll be a regular job.
- Find all of the SSH keys you want to replace.
I hate this part.
This generally referred to as Key Rotation. It applies to everything from SSH keys, to API keys in running apps.
There are automated ways to do this with ease, but it's very simple to do with a single script, and some sort of secure key/value store (bitwarden, Vault, etcd...whatever).
The process is basically something like:
- Create a script that runs on cron to check for a key at your k/v store at an expected location, like
/ssh_keys/host1-private-12.1.25and/ssh_keys/host1-public-12.1.25 - Deploy this script to all machines you wish to regularly rotate keys on and ensure running properly
- Generate new keys and put them in your k/v store at some versioned location/path like
/ssh_keys/host1-private-12.21.25and/ssh_keys/host1-pub-12.21.25 - Update your local script that regularly grabs these updated keys to point to the new version uploaded, bonus if your store can symlinkto some other locations like
/ssh_keys/host1-private-current - Wait X period of time to ensure all hosts get whatever key they need
Your script can clear the old keys if needed but simply validating them in the access change serves the same effect. Up to you.