简体   繁体   English

Jenkins无法通过SSH进入github

[英]Jenkins cannot SSH into github

Running ubuntu on EC2 instance. 在EC2实例上运行ubuntu。 I want to setup Jenkins SSH with my github server, but when I run the command 我想用我的github服务器设置Jenkins SSH,但是当我运行命令时

ssh -vT git@github.com

I receive the following output: 我收到以下输出:

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [192.30.253.113] port 22.
ssh: connect to host github.com port 22: Connection timed out

My ssh key for jenkins is located in the /var/lib/jenkins/.ssh folder, but it looks as if ssh config data is being read in the /etc/ folder 我的jenkins的ssh密钥位于/var/lib/jenkins/.ssh文件夹中,但是看起来好像在/ etc /文件夹中正在读取ssh配置数据

I have added the public SSH key to my github account and have verified that I did so as one line. 我已将公共SSH密钥添加到我的github帐户中,并确认已这样做(作为一行)。

What else am I missing? 我还想念什么?

I came across this Creating SSH keys for Gerrit and Hudson as a potential reason why it is not connecting, but I find it highly unlikely that the last time this occurred for somebody was 5 years ago. 我遇到了这个为Gerrit和Hudson创建SSH密钥的问题,这可能是它没有连接的潜在原因,但是我发现上一次发生这种情况的可能性极小是在5年前。

This looks more like a networking issue as you receive a Connection timed out error. 当您收到“ Connection timed out错误时,这看起来更像是网络问题

So, first check that you can really connect to the github server , eg using nmap or telnet ; 因此, 首先检查您是否真的可以连接到github服务器 ,例如使用nmaptelnet the output should look like this if networking is ok: 如果联网正常,输出应如下所示:

$ telnet github.com 22
Trying 192.30.253.112...
Connected to github.com.
Escape character is '^]'.
SSH-2.0-libssh-0.7.0

ssh keys are usually located in $HOME/.ssh/ (where $HOME is the home directory of the user that runs the Jenkins master) -- the folder /var/lib/jenkins/.ssh looks at least unusal. ssh密钥通常位于$HOME/.ssh/ (其中$HOME是运行Jenkins主服务器的用户的主目录)-文件夹/var/lib/jenkins/.ssh看起来至少没有用。

The directory /etc/ssh contains system-wide ssh configuration data, it will always be read and is not intended for user-specific configuration items. 目录/etc/ssh包含系统范围的ssh配置数据,将始终读取该目录,并且不适用于用户特定的配置项目。

Turns out that EC2 doesn't seem to let me connect to github via port 22. I tested this via Alex O's suggestion that I attempt to telnet into git 事实证明EC2似乎不允许我通过端口22连接到github。我通过Alex O的建议(尝试将telnet接入git)对此进行了测试

My solution: 我的解决方案:

  1. Use SSH through the HTTPS port 通过HTTPS端口使用SSH
  2. Change the config file for github to ssh through 443 将github的配置文件更改为ssh通过443
  3. Profit 利润

Major cred to @AlexO 主要信任@AlexO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM