AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1018064
Accepted
Shaz Hemani
Shaz Hemani
Asked: 2020-05-22 03:31:23 +0800 CST2020-05-22 03:31:23 +0800 CST 2020-05-22 03:31:23 +0800 CST

SSH连接在gitea中不起作用

  • 772

我已经使用 docker-compose 设置了 gitea,我机器的外部 SSH 端口是 4444,我在 sshd_config 中设置

version: '2'
volumes:
  gitea:
  postgres:
networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:latest
    env_file:
      - .env
    restart: always
    networks:
      - gitea
    volumes:
      - gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "2222:22"
    depends_on:
      - postgres
  postgres:
      image: postgres:9.6
      restart: always
      env_file:
        - gittea_db.env
      networks:
        - gitea
      ports:
        - "5432:5432"
      volumes:
        - postgres:/var/lib/postgresql/data

以下是 .env 文件

USER_UID=1002
USER_GID=1001
DB_TYPE=postgres
DB_HOST=postgres:5432
DB_NAME=gittea
DB_USER=gittea
DB_PASSWD=password12
INSTALL_LOCK=True
APP_NAME=myapp
RUN_MODE=prod
DOMAIN=source.smarticlelabs.com
ROOT_URL=https://source.smarticlelabs.com
SSH_LISTEN_PORT=22
SSH_PORT=2222

但是当我在添加我的 ssh 密钥后尝试克隆一个 repo 时,我收到了这个错误

git clone ssh://[email protected]:2222/superadmin/testrepo.git
Cloning into 'testrepo'...
ssh: connect to host 51.15.245.237 port 2222: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
vps docker-compose gitea
  • 1 1 个回答
  • 4396 Views

1 个回答

  • Voted
  1. Best Answer
    Bodo Hugo Barwich
    2020-07-10T02:41:17+08:002020-07-10T02:41:17+08:00

    正如其他人指出的那样,这实际上可能是防火墙问题。
    要解决这个问题,您首先应该验证您的容器实际上正在运行docker-compose ps

    # docker-compose ps
     Name                Command               State           Ports         
    -------------------------------------------------------------------------
    server               [cmd ...]             Up              0.0.0.0:22->2222/tcp
    

    接下来,您应该检查您的Docker主机,该端口实际上是通过以下方式公开的netstat -lpn|grep -i 2222:

    # netstat -lpn|grep -i 2222
    tcp6       0      0 :::2222                 :::*                    LISTEN      7216/docker-proxy-c
    

    这也应该与本地Docker主机防火墙匹配iptables-save|grep -i 2222:

    # iptables-save|grep -i 2222
    -A POSTROUTING -s 172.18.0.2/32 -d 172.18.0.2/32 -p tcp -m tcp --dport 2222 -j MASQUERADE
    -A DOCKER ! -i br-0383ea873b82 -p tcp -m tcp --dport 2222 -j DNAT --to-destination 172.18.0.2:2222
    -A DOCKER -d 172.18.0.2/32 ! -i br-0383ea873b82 -o br-0383ea873b82 -p tcp -m tcp --dport 2222 -j ACCEPT
    

    如果所有这些检查都是肯定的,则可能是您的 Internet IP上的外部防火墙存在问题51.15.245.237

    您可以通过从与您的Docker主机位于同一 IntraNet 上的另一台主机连接来检查这一点。

    • 2

相关问题

  • VMWare 服务器 VM 网络利用率

  • 任何 ASP.Net 网站都需要 1 分钟才能加载?Html 站点立即加载

  • 如何学习/掌握(教程)管理 VPS?- 新手 VPS 用户 [关闭]

  • 任何人都有在托管/数据中心理想的共享/vps 服务器设置的示例拓扑?

  • Virtuozzo VPS 上的 MAC 地址

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve