3

I'd like to add my SSH key to authorized keys on a git server (a company server), to not have to insert my password every time I push. However for some reason I cannot make that working.

What I tried:

ssh-copy-id user@server
/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
user@server's password: 
fatal: unrecognized command '
        umask 077 ;
        mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;
        if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi'

When I try to ssh to the git server, I get the following response:

fatal: Interactive git shell is not enabled.
hint: ~/git-shell-commands should exist and have read and execute access.

Apparently the user account is using git-shell and it seems that it does not understand the usual shell commands.

Is it still possible to add the public SSH key to the git server user account somehow? Is there perhaps some git command which would allow me to put my public SSH key to the list?

The only access I have to the git server is via the command line and there is the GitWeb interface running (but in there I do not see any option to install the SSH key either).

EmDroid
  • 5,918
  • 18
  • 18
  • If you've only been given git-shell access, I imagine you're going to have trouble adding an ssh key. Have you spoken to your company's sysadmin/server maintainer? – Holloway Mar 18 '16 at 10:53
  • Not yet, I tried to figure this out first. But seems there is no other option, so I'll check with them. – EmDroid Mar 18 '16 at 11:29

1 Answers1

1

you should contact your sysadmin, make sure user home dir permisson without write permission for others.

and for /home/user/.ssh permission advice to be its group and ownwer itself with 0700, and the /home/user/authorized_keys permission 0600.

I assume that user group is git.

# cd /home/user
# chown -R user:git  .ssh
# chmod 0700 .ssh
# chmod 0600 .ssh/authorized_keys

If this file(.ssh/authorized_keys), the ~/.ssh directory, or the user's home directory are writable by other users, then the file could be modified or replaced by unauthorized users. In this case, sshd will not allow it to be used unless the StrictModes option has been set to “no”.

More infomation just see man 8 sshd

Codcodog
  • 11
  • 2
  • I don't think the issue has anything to do with permissions on `.ssh`. It's the `git-shell` not allowing to execute that particular command. – bluenote10 Jun 18 '19 at 09:30