7

I am trying to use deployment keys for a repository which belongs to an organization (for which I am an administrator).

I created a private/public key pair, the public was pasted into the 'deployment keys' window, and accepted. I then tried to connect via git pull from a distant repository:

git add origin git@myserver.com:/organization/therepo.git
git pull

I keep being asked for the password for the user git. I tried to use instead the users git, gogs, <my login>, <the name or the organization> -- I am being asked for the password every time.

I tried a simple ssh -v to check which key is provided to gogs: it is the right one (the private key above, corresponding to the deployment (public) key).

Which user should I use to connect?

WoJ
  • 27,165
  • 48
  • 180
  • 345
  • I looked at some example `gogs` repo URLs. Should the forward slash before "organization" be there? –  Jun 30 '16 at 14:38
  • @DavidCullen: you are right, I also tried without the slash initially. Still, the authentication does not go through so this would not be the issue (I would get a `repository ... not found` kind of error) – WoJ Jun 30 '16 at 15:23
  • What did you use for "Run User"? Does that account exist? If so, is that user running `gogs`? –  Jun 30 '16 at 20:45
  • @DavidCullen: Thanks for the update - this is a good path for troubleshooting. I checked, the user is `git`. I see that its `.ssh/authorized_keys` has the key I put via the web interface. I will try to debug the `ssh` connexion form the sever end to see how it looks like from that side. – WoJ Jul 01 '16 at 07:22

1 Answers1

4

All credit for the troubleshooting ideas goes to David Cullen (via his comments)

The problem was that I was calling the wrong sshd service.

My GOGS service runs in docker and the ssh port is different from the one of the host server (which is what I was calling using the default port 22):

# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                           NAMES
86ddbabc8cbb        gogs/gogs           "docker/start.sh /bin"   13 days ago         Up 3 minutes        0.0.0.0:3000->3000/tcp, 0.0.0.0:10022->22/tcp   gogs

By using an ~/.ssh/config file like that

Host    my.git.server.com
        Port 10022
        IdentityFile    /var/www/.ssh/my.private.key.openssh
        IdentitiesOnly yes

I now successfuly pull the GOGS repository from a remote server:

$ git pull ssh://git@my.git.server.com:/organisation/therepo
From ssh://my.git.server.com:/organisation/therepo
 * branch            HEAD       -> FETCH_HEAD
Already up-to-date.

Please note that there is a slash before organisation (re: initial comments)

Community
  • 1
  • 1
WoJ
  • 27,165
  • 48
  • 180
  • 345