[ Docker + Gogs + SSH ] Gogs: Repository owner does not exist

#1

Docker运行镜像的命令如下:

docker run -d --name=gogs \
-p 10022:22 -p 3000:3000 \
-v /web/gogs:/data \
--restart=always gogs/gogs 

id git,虚拟与真实的 git 都是 1000,运行

git clone https://gogs.makeit.vip/makeit/api.git

输入用户名与密码,正常克隆

但是用 ssh 问题就来了

我是这么配置的

  1. 切换到 git 用户

  2. 运行 ssh-keygen -t rsa -C "makeit@makeit.vip" 命令生成密钥

  3. 将生成的 id_rsa.pub 添加进后台管理页面的 用户设置 -> SSH密钥 菜单中

  4. authorized_keys 已生效

  5. 添加 .ssh 软链(即 ln -s /web/gogs/git/.ssh ~/.ssh

  6. 切换至 root 用户,生成 /app/gogs/gogs 文件,并配置了如下内容:

     #!/bin/sh
     ssh -p 10022 -o StrictHostKeyChecking=no git@127.0.0.1 \
     "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@"
    
  7. 修改 /app/gogs/gogs 文件权限,即运行 chmod 755 /app/gogs/gogs(参考资料:http://www.ateijelo.com/blog/2016/07/09/share-port-22-between-docker-gogs-ssh-and-local-system

  8. 另外,根据其它相关资料,将 ~/.ssh 目录权限更改为 700,且 authorized_keys 的权限为 600

  9. 似乎已经准备就绪,尝试运行了一下 ssh -v git@gogs.makeit.vip,返回的结果如下:

     .....
     debug1: Authentication succeeded (publickey).
     Authenticated to gogs.makeit.vip ([IP]:22).
     debug1: channel 0: new [client-session]
     debug1: Requesting no-more-sessions@openssh.com
     debug1: Entering interactive session.
     debug1: pledge: network
     debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
     debug1: Remote: Forced command.
     debug1: Remote: Port forwarding disabled.
     debug1: Remote: X11 forwarding disabled.
     debug1: Remote: Agent forwarding disabled.
     debug1: Remote: PTY allocation disabled.
     debug1: Remote: Forced command.
     debug1: Remote: Port forwarding disabled.
     debug1: Remote: X11 forwarding disabled.
     debug1: Remote: Agent forwarding disabled.
     debug1: Remote: PTY allocation disabled.
     debug1: Sending environment.
     debug1: Sending env LANG = en_US.UTF-8
     PTY allocation request failed on channel 0
     Gogs: Repository owner does not exist
     debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
     debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
     debug1: channel 0: free: client-session, nchannels 1
     Connection to gogs.makeit.vip closed.
     Transferred: sent 3148, received 3236 bytes, in 0.2 seconds
     Bytes per second: sent 13977.2, received 14367.9
     debug1: Exit status 1
    
  10. 已经连接成功 Authentication succeeded,但出现了 Gogs: Repository owner does not exist

  11. 执行 ssh -T git@gogs.makeit.vip 结果同样是 Gogs: Repository owner does not exist

  12. 另外,我是用 git 用户执行 docker 执行,运行 gogs 的,且如果我将 app.ini 配置文件里头的 SSH_PORT 改成 10022 的话,是可以 clone 成功的

    折腾了好久,不知道哪个配置环节有误,没找到解决的办法,求助 … 谢谢