Skip Navigation

Sync bash aliases and ssh keys across devices

How do you guys quickly sync your settings (especially bash aliases and ssh keys) across your machines?

Ideally i want a simple script to run on every new server I work with. Any suggestions?

42 comments
  • On my devices like PCs, laptops or phones, syncthing syncs all my .rc files, configs, keys, etc.

    For things like servers, routers, etc. I rely on OpenSSH's ability to send over environmental variables to send my aliases and functions.
    On the remote I have
    [ -n "$SSH_CONNECTION" ] && eval "$(echo "$LC_RC" | { { base64 -d || openssl base64 -d; } | gzip -d; } 2>/dev/null)"
    in whatever is loaded when I connect (.bashrc, usually)
    On the local machine
    alias ssh="$([ -z "$SSH_CONNECTION" ] && echo 'LC_RC=$(gzip < ~/.rc | base64 -w 0)') ssh'

    That's not the best way to do that by any means (it doesn't work with dropbear, for example), but for cases like that I have other non-generic, one-off solutions.

  • Syncthing. If you want flatpak, syncthingy.

    Its simply best, does all the annoying background things like webUI, machines, versioning, verifying etc. If you disable global discovery you can use it tough LAN only

  • Use a git repo and stow tool. For updating, you only need run git pull (and stow if you create config for a new software). If you modify some config, just git add && git commit && git push.
    \ With this way, you can also record change history of your config.

  • Several good suggestions on here already. Home manager might be another approach.

42 comments