Docker 自建gitea 时候,出现ssh clone 失败的问题

我使用docker搭建gitea的时候出现ssh clone 失败的问题

docker compose 配置

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:1.19.0-rc1
    container_name: gitea119
    environment:
      - USER_UID=1001
      - USER_GID=1005
      - GITEA__database__DB_TYPE=mysql
      - GITEA__database__HOST=db:3306
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=gitea
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      # 苹果的 用户下ssh目录
      # - /Users/git/.ssh/:/data/git/.ssh
      # liunx home ssh目录
      - /home/git/.ssh/:/data/git/.ssh
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "222:22"
    depends_on:
      - db

  db:
    image: mysql:latest
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=gitea
      - MYSQL_DATABASE=gitea
    networks:
      - gitea
    volumes:
      - ./mysql:/var/lib/mysql

gitea 相关配置

Git 版本
2.38.4, Wire Protocol Version 2 Enabled
仓库根目录
/data/git/repositories
静态文件根目录
/app/gitea
自定义文件根路径
/data/gitea
日志路径
/data/gitea/log
脚本类型
bash
反向代理认证
X-WEBAUTH-USER
GITEA_CUSTOM
/data/gitea
GITEA_WORK_DIR
/app/gitea
SSH 配置
启用
使用内置 SSH 服务器
SSH 服务器域名
192.168.2.105
端口
222
监听端口
22
根目录
/data/git/.ssh
密钥测试路径
/tmp
密钥生成器('ssh-keygen')路径
ssh-keygen
密钥最小长度检查
密钥最小长度限制
map[ecdsa:256 ecdsa-sk:256 ed25519:256 ed25519-sk:256 rsa:2047]

ssh测试

Host gitea
  HostName 192.168.2.105
  Port 222
  User git
  PreferredAuthentications publickey
  IdentityFile C:\Users\yaoyoutian\.ssh\gitea_id_rsa

$ ssh -T gitea
Hi there, yyt! You've successfully authenticated with the key named win 主
机, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.

ssh 克隆

git clone ssh://git@192.168.2.105:222/yyt/demo.git
Cloning into 'demo'...
git@192.168.2.105: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

http 克隆成功

git clone http://192.168.2.105:3000/yyt/demo.git
Cloning into 'demo'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (4/4), done.

检查了authorized_keys 文档也是正常

根据gitea docker 直通文档操作了 也还是会出现一样的 问题
gitea docker 直通文档

ssh 配置文件authorized

ssh 配置文件
微信截图_20230620110304

Is ssh-agent running? I think that may be issue, see 将 SSH 密钥添加到 ssh-agent.

解决了吗? 我现在一直要我输入密码 怎么输入都不对

               哈哈 ,放弃了 , 我也没有解决,查了  很多资料 也没有找到解决办法

截屏2023-10-29 17.39.59
需要从默认配置文件/etc/ssh/ssh_config中配置默认的密钥名称
也可以通过~/.ssh/config加入IdentityFile ~/.ssh/gitea_rsa自行更改指定的ssh key