github的ssh通过http代理来配置实现

来源:互联网 发布:linux 查看tomcat日志 编辑:程序博客网 时间:2024/05/06 20:19

如果在公司内通过代理上网或者因为某些已知的非可抗力因素导致我们上网必须通过代理,用本地客户端访问github时,如果不做配置的话通过ssh来克隆repository的时候,用原生命令是不能直接访问的,需要配置下代理。

方法1. 配置ssh的配置文件

#回归家目录thinker@thinker-young MINGW64 ~/.ssh$ cd# 查看家目录在windows中的位置thinker@thinker-young MINGW64 ~$ pwd/c/Users/thinker#切到ssh的配置文件下thinker@thinker-young MINGW64 ~$ cd .ssh# 创建配置文件thinker@thinker-young MINGW64 ~/.ssh$ vi config#写入下面的内容#其中 10.80.22.24是代理服务器的地址,80是端口thinker@thinker-young MINGW64 ~/.ssh$ cat configHost github.comProxyCommand connect -H 10.80.22.42:80 %h %p#ProxyCommand ~/.ssh/ssh-https-tunnel %h %pPort 443Hostname ssh.github.com#保存退出thinker@thinker-young MINGW64 ~/.ssh

方法2.如果代理需要密码访问,可以用下面的方法

下载一个脚本放到.ssh目录下,命名为ssh-https-tunnel
下载地址:https://zwitterion.org/software/ssh-https-tunnel/ssh-https-tunnel

2.1 配置ssh的配置文件

#回归家目录thinker@thinker-young MINGW64 ~/.ssh$ cd# 查看家目录在windows中的位置thinker@thinker-young MINGW64 ~$ pwd/c/Users/thinker#切到ssh的配置文件下thinker@thinker-young MINGW64 ~$ cd .ssh# 创建配置文件thinker@thinker-young MINGW64 ~/.ssh$ vi config#写入下面的内容thinker@thinker-young MINGW64 ~/.ssh$ cat configHost github.comProxyCommand ~/.ssh/ssh-https-tunnel %h %pPort 443Hostname ssh.github.com#保存退出thinker@thinker-young MINGW64 ~/.ssh

2.2 配置代理服务器和密码

打开刚才下载ssh-https-tunnel这个文件,完成代理服务器ip和端口,及用户名和密码的配置:

##################################  Start User Configuration  ################################### Proxy detailsmy $host = "10.80.22.44";my $port = 80;# Basic Proxy Authentication - leave empty if you don't need itmy $user = "username";my $pass = "userpass";# Add an entry to your ~/.ssh/config that so "ssh remote.example.org"# uses this program to proxy the connection.##    host remote.example.org#        ProxyCommand /path/to/ssh-https-tunnel %h %p#        Port 443#        ServerAliveInterval 10## The last option enables Keep Alives to avoid the problem of many# proxies timing out inactive connections.  Check your ssh client's# documentation for details.## If you are behind a Microsoft ISA server, or similar proxy that uses# NTLM, see http://www.google.com/search?q=ntlm+proxy+auth for ideas.##################################   End User Configuration   ##################################

如果是用的微软的NTLM认真的代理的话可以参考这位道友的文章:
http://blog.csdn.net/bluishglc/article/details/37600773

0 0