Search code examples
gogs

Which user to use with deployment keys?


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 [email protected]:/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?


Solution

  • 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://[email protected]:/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)