I'm trying to set up a git repo for a project and therefore I want to make use of ssh keys in order to not re-enter my password every time.
I stumbled over the possibility to let ssh do the copying work with ssh-copy-id
, however it does not seem to work out for me.
$ ssh-copy-id -i git@server
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:
"/c/Users/Me/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to
filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are
prompted now it is to install the new keys
git@server's password:
sh: 1: cannot create .ssh/authorized_keys: Permission denied
Edit: I solved the problem the following way:
- logged in root via su
- changed ownership of the authorized_keys file via chown git /home/git/.ssh/authorized keys
to git
- then logged git back in
- lastly changed the rw permission to 600 via chmod 600 ~/.ssh/authorized keys
and successfully copied the key over
.ssh
directory usingls -ld .ssh
in the git server? The user and group ownership should begit:git
and permission should be700
– Sourav Jun 25 '17 at 8:13drwx------ 2 git git 4096 Jun 25 02:49 /home/git/.ssh
– Tom Connery Jun 25 '17 at 9:45touch .ssh/authorized_keys
on the server? – l0b0 Jun 25 '17 at 9:48git@rs000018:~$ touch .ssh/authorized_keys
touch: cannot touch ‘.ssh/authorized_keys’: Permission denied
Seems like a clear no =/ – Tom Connery Jun 25 '17 at 12:28