docker - 如何使用 ssh 代理在 gitlab ci 中运行部署作业?

标签 docker ssh deployment proxy gitlab-ci

我在伊朗有一台服务器,我想使用 gitlab ci 打开一个到我的服务器的 ssh 隧道。

但是感谢谷歌云服务,gitlab 看不到伊朗 IP。

有没有什么办法可以使用伊朗以外的中间服务器打开从 gitlab 到我的代理服务器以及从那个到我的伊朗服务器的代理隧道,然后使用 docker 从 gitlab registery 中提取图像?

考虑伊朗服务器无法连接到 gitlab,而 gitlab 也无法连接到伊朗服务器。

谢谢

最佳答案

我用这样的代码成功了

before_script:
  - apt-get update -y
  - apt-get install openssh-client curl -y


integration:
  stage: integration
  script:
    - mkdir ~/.ssh/
    - eval $(ssh-agent -s)
    - echo "$SSH_KEY" | tr -d '\r' > ~/.ssh/id_rsa
    - chmod 600 ~/.ssh/id_rsa
    - ssh -fN -L 1029:localhost:1729 user@$HOST -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no 2>&1
    - ssh -fN -L 9013:localhost:9713 user@$HOST -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no 2>&1

关于docker - 如何使用 ssh 代理在 gitlab ci 中运行部署作业?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53898891/

相关文章:

python - Docker 构建似乎看不到 requirements.txt,即使它在同一目录中

ssh - 你能通过 SSH/SCP 运行 gitk 吗?

java - RETEasy+JUnit : Is it possible to test the web services in the same WAR?

iis - 如何配置 .net 核心 API 以在 IIS 中工作?

php - 如何使用 ssh2_publickey_add 添加公钥

deployment - 使用 Visual Studio 2012, list 已签名,但程序集未签名

docker - 如何保存 Docker 容器状态

c - 在 docker 容器内运行时的不同结果

docker - docker :错误:无法删除一个或多个图像

powershell - 使用System.Diagnostics.Process在标准输入上将y输入到Plink?