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

如果在公司内通过代理上网或者因为某些已知的非可抗力因素导致我们上网必须通过代理,用本地客户端访问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 config
Host github.com
ProxyCommand connect -H 10.80.22.42:80 %h %p
#ProxyCommand ~/.ssh/ssh-https-tunnel %h %p
Port 443
Hostname 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 config
Host github.com
ProxyCommand ~/.ssh/ssh-https-tunnel %h %p
Port 443
Hostname ssh.github.com

#保存退出
thinker@thinker-young MINGW64 ~/.ssh

2.2 配置代理服务器和密码

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

################################
##  Start User Configuration  ##
################################

# Proxy details
my $host = "10.80.22.44";
my $port = 80;

# Basic Proxy Authentication - leave empty if you don't need it
my $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

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贤时间

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值