1

I have set up a remote Git repo and can push to it with

git push remote master

However, it always asks me for my password. I don't want to have to enter my password every time I do this. If this were GitHub, I'd locally generate an SSH key and then go into the GitHub settings and add it. Since this isn't GitHub, I can't do that.

So how do I associate my SSH key with my remote Git repo through SSH terminal commands?

brentonstrine
  • 21,694
  • 25
  • 74
  • 120
  • `ssh -vvv git-user@git-server`. If `ssh-copy-id` and/or properly setting up permissions and `authorized_keys` file does not help, talk with the server administrator. – Jakuje Jun 28 '17 at 11:22

2 Answers2

1

Use ssh-copy-id or a similar metod to copy public key to the server. See https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server

phd
  • 82,685
  • 13
  • 120
  • 165
  • Thanks, good answer. Was able to use it and it put my public key inside `~/.ssh/authorized_keys`, but it still asks for my password. Not sure why. Possibly because I don't have root access? – brentonstrine Jun 27 '17 at 23:12
  • Do you have a passphrase protecting you private key? You can use [ssh agent](https://stackoverflow.com/a/10032655/7976758) to store you key; you still will need to enter passphrase once per boot (once per ssh agent restart, to be precise). You can [remove passphrase](https://stackoverflow.com/a/44789213/7976758) but you must protect your private key from leaking. – phd Jun 27 '17 at 23:20
  • I did have a passphrase. I started over with a new key (without a passphrase) and got the same results. – brentonstrine Jun 27 '17 at 23:40
0

I think this will help you I faced the same problem. you have to create a passphrase less ssh key. you can follow the procedure. it solved my problem https://linuxize.com/post/how-to-setup-passwordless-ssh-login/