“Not really a script, but a `.ssh/config` to automatically deploy parts of my local cli environment” (comment)
recommended by 3 users | 2022 | hoechst on: Ask HN: Can I see your scripts? | command line | original thread |
hoechst on Aug 15, 2022 | on: Ask HN: Can I see your scripts? | view on HN

Not really a script, but a `.ssh/config` to automatically deploy parts of my local cli environment to every server i connect to (if username and ip/hostname matches my rules).

On first connect to a server, this sync all the dotfiles i want to a remote host and on subsequent connects, it updates the dotfiles.

Idk if this is "special", but I haven't seen anyone else do this really and it beats for example ansible playbooks by being dead simple.

   Match Host 192.168.123.*,another-example.org,*.example.com User myusername,myotherusername
      ForwardAgent yes
      PermitLocalCommand yes
      LocalCommand rsync -L --exclude .netrwhist --exclude .git --exclude .config/iterm2/AppSupport/ --exclude .vim/bundle/youcompleteme/ -vRrlptze "ssh -o PermitLocalCommand=no" %d/./.screenrc %d/./.gitignore %d/./.bash_profile %d/./.ssh/git_ed25519.pub %d/./.ssh/authorized_keys %d/./.vimrc %d/./.zshrc %d/./.config/iterm2/ %d/./.vim/ %d/./bin/ %d/./.bash/ %r@%n:/home/%r
3 users recommended this comment. What they said:
rovr138 Aug 29, 2022 | on: Chezmoi – Manage your dotfiles across multiple diverse… | context

2 weeks ago someone asked

> Ask HN: Can I see your scripts?[1]

I really like this[2] solution from /u/hoechst,

> Not really a script, but a `.ssh/config` to automatically deploy parts of my local cli environment to every server i connect to (if username and ip/hostname matches my rules).

> On first connect to a server, this sync all the dotfiles i want to a remote host and on subsequent connects, it updates the dotfiles.

> Idk if this is "special", but I haven't seen anyone else do this really and it beats for example ansible playbooks by being dead simple.

    Match Host 192.168.123.*,another-example.org,*.example.com User myusername,myotherusername
       ForwardAgent yes
       PermitLocalCommand yes
       LocalCommand rsync -L --exclude .netrwhist --exclude .git --exclude .config/iterm2/AppSupport/ --exclude .vim/bundle/youcompleteme/ -vRrlptze "ssh -o PermitLocalCommand=no" %d/./.screenrc %d/./.gitignore %d/./.bash_profile %d/./.ssh/git_ed25519.pub %d/./.ssh/authorized_keys %d/./.vimrc %d/./.zshrc %d/./.config/iterm2/ %d/./.vim/ %d/./bin/ %d/./.bash/ %r@%n:/home/%r

[1] https://news.ycombinator.com/item?id=32467957

[2] https://news.ycombinator.com/item?id=32468605

InvaderFizz Aug 17, 2022 | on: Using SSH_config Match to connect to a host using multiple… | context

The dotfile post: https://news.ycombinator.com/item?id=32468605

I bookmarked that for reference last night.

olejorgenb Aug 22, 2022 | on: SSH tips and tricks | context

I haven't tested it yet, but the tip from https://news.ycombinator.com/item?id=32468605 seem neat: (automatically copy config files on connect)

   Match Host 192.168.123.*,another-example.org,*.example.com User myusername,myotherusername
      ForwardAgent yes
      PermitLocalCommand yes
      LocalCommand rsync -L --exclude .netrwhist --exclude .git --exclude .config/iterm2/AppSupport/ --exclude .vim/bundle/youcompleteme/ -vRrlptze "ssh -o PermitLocalCommand=no" %d/./.screenrc %d/./.gitignore %d/./.bash_profile %d/./.ssh/git_ed25519.pub %d/./.ssh/authorized_keys %d/./.vimrc %d/./.zshrc %d/./.config/iterm2/ %d/./.vim/ %d/./bin/ %d/./.bash/ %r@%n:/home/%r