{"id":5273,"date":"2020-04-08T08:36:30","date_gmt":"2020-04-08T08:36:30","guid":{"rendered":"https:\/\/wp.fisher.hu\/?p=5273"},"modified":"2020-04-14T15:19:18","modified_gmt":"2020-04-14T15:19:18","slug":"a-not-so-insecure-git-v0","status":"publish","type":"post","link":"https:\/\/wp.fisher.hu\/a-not-so-insecure-git-v0\/","title":{"rendered":"A not so insecure git v0"},"content":{"rendered":"\n

At least, I hope.<\/p>\n\n\n\n

The problem: I need git. Ok, go github. Yapp, but I need the git for some sensitive-ish data. Nothing really sensitive<\/a>, or confidental, but yeah, no github.<\/p>\n\n\n\n

Ok, then have my own. Easy, git init –bare and bascially all set.<\/p>\n\n\n\n

We are ready.<\/p>\n\n\n\n

Hm, but I know I usually forget to update the git tree on all the nodes I already deployed. I need, really need automatic updates.<\/strong><\/p>\n\n\n\n

Ok, create a timer, a service and a script (Do you rember when it was only one line in the crontab?) whatever.<\/p>\n\n\n\n

Oh wait. The git repo is available via ssh. I don’t want to put my private key on all the nodes…<\/p>\n\n\n\n

Think, think, think<\/a>…<\/p>\n\n\n\n

Hmm, create a new keypair, only for the git use:<\/p>\n\n\n\n

ssh-keygen -f git_id_rsa<\/pre>\n\n\n\n

Put it any convenient folder, and set up the server side. Put the public key into the authorized_keys and prepend with the “command” stuff (adapt to your system):<\/p>\n\n\n\n

$ cat .ssh\/authorized_keys\ncommand=\"git-upload-pack '\/home\/fisher\/git\/?????.git'\" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCpbipOc6rtzXH5B7vhQ.....<\/pre>\n\n\n\n

This forces anyone using this key to run this command <\/a>only.<\/p>\n\n\n\n

Now pimp up the git to use the ssh command a bit differently:<\/p>\n\n\n\n

git -c core.sshCommand=\"ssh -i whereverisyourkey\/git_id_rsa\" pull origin master<\/pre>\n\n\n\n

Craft this command into your systemd service file, or crontab or any other scheduler something.<\/p>\n\n\n\n

Uh, this is baaad, anyone has the (private) key, can steal your full git repo!<\/p>\n\n\n\n

Absolutely true. But if someone managed to get this key, then probably already took the full repo too (and many other things). But this key allows a read-only access so cannot alter the repo content. Unless if there is a way in the git protocol, I never checked, tbh. And the important thing, this key not allows remote login.<\/p>\n\n\n\n

Note: if the attacker manages to alter the repo content and somehow able to push it into your central git server, you are in trouble.<\/strong><\/p>\n\n\n\n

Pff… why bother then with all this crap? See above. You get automatic updates, and even can push the changes if you log in with your private key (or use your secure password).<\/p>\n","protected":false},"excerpt":{"rendered":"

At least, I hope.<\/p>\n","protected":false},"author":1,"featured_media":5278,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[135,134],"_links":{"self":[{"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/posts\/5273"}],"collection":[{"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/comments?post=5273"}],"version-history":[{"count":8,"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/posts\/5273\/revisions"}],"predecessor-version":[{"id":5283,"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/posts\/5273\/revisions\/5283"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/media\/5278"}],"wp:attachment":[{"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/media?parent=5273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/categories?post=5273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.fisher.hu\/wp-json\/wp\/v2\/tags?post=5273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}