docker - 使用 docker 在 gitea 上 ssh

标签 docker ssh gitea

我刚刚在 Linux mint 19 上使用 docker 安装了 gitea,我在旧的 gitea 安装中使用了/data,所以我有一个填充数据库和存储库。当我访问网络时,它似乎工作正常。

问题是使用SSH:

➜  /tmp sudo git clone git@gitealocal:felipe/test.git
Cloning into 'test'...
ssh: connect to host gitealocal port 22: Connection refused
fatal: Could not read from remote repository.

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


➜  /tmp ssh -vT gitealocal
OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/felipe/.ssh/config
debug1: /home/felipe/.ssh/config line 16: Applying options for gitealocal
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to gitealocal [127.0.1.1] port 10022.
debug1: Connection established.
debug1: identity file /home/felipe/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/felipe/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/felipe/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/felipe/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/felipe/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/felipe/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/felipe/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/felipe/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.1
ssh_exchange_identification: Connection closed by remote host

我检查目录和文件的权限 /var/lib/gitea/ssh但似乎是对的。 drwx-------rw-------

最佳答案

您需要公开 ssh 端口 22当您启动 docker 容器时,请尝试:

docker run --expose 22 ...

或者甚至更好地添加 EXPOSE 22根据 official docs 到 Dockerfile 和 SSH 登录修复程序:
FROM ubuntu:16.04

RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:screencast' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd

ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

关于docker - 使用 docker 在 gitea 上 ssh,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54458450/

相关文章:

git - 如何远程转储gitea存储库

docker - 跨容器运行持久保存 Dockerized Consul KV Store

git - Android studio git 使用私钥

git - 多个 Vagrant 盒的最佳实践

git - 通过 HTTP 和 SSH 通过 Ingress 访问 Kubernetes Git Container

linux - Gitea无法获取存储库

linux - 如何模拟 Docker 注册表宕机的情况

sockets - 使用 golang docker 引擎创建容器时出错

amazon-web-services - 如何在 EC2 Mac 实例上安装并运行 docker.app

nginx - Gitea 和 Nginx 配置