Pages: Welcome | Projects

Git Push speedup hack, with Systemd

2017/7/9

It is two years already I've published that quick post about how to speed-up your GitHub interaction. Well, I used it a lot, and of course not just with GitHub. And an interesting idea popped into my mind: using it within your Systemd configuration…

There are a couple of places from which Systemd can load unit files on behalf of your user. They can be found in the systemd.unit manpage.

Here's the content of my $HOME/.config/systemd/user/keepup@.service:

[Unit]
Description=Persistent ssh connection towards %i
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/ssh -v -N %i

Given this configuration in my /.ssh/config:

ControlMaster auto
ControlPath /tmp/ssh-%u@%l-%r@%h:%p
ServerAliveInterval=60

Host github.com
    User git
    IdentityFile ~/.ssh/github-id_rsa

I can simply run the following:

systemctl --unit start keepup@github.com

And I don't really need to have a shell open for it anymore :)