We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在上一篇《使用 root 用户登陆到腾讯云的主机》的结尾,我提到在特定网络环境下通过 ssh 访问服务器的连接会被屏蔽,这两天时不时的就会琢磨怎么解决这个问题,今天突然想到,ssh 能不能走代理访问到服务器?
谷歌了一番,发现真的可以……
当然,这样做的前提是得自备一个梯子。我在 macOS 用的是 ShadowsocksX-NG,在偏好设置里可以看到它在本地的 1086 端口开启了 Socks5 代理,那么通过代理访问服务器可以这么做:
# 这里假设你已经在 ~/.ssh/config 为 myserver 配置了连接信息 $ ssh myserver -o "ProxyCommand=nc -X 5 -x 127.0.0.1:1086 %h %p"
连接成功后,可以运行 tac /var/log/auth.log | grep sshd 查看自己最近是从什么 IP 地址登陆的,你会发现登陆的 IP 和你在 ShadowsocksX-NG 中当前使用的服务器节点的 IP 是一样的。
tac /var/log/auth.log | grep sshd
当然,-o 后面的 ProxyCommand 也是可以在 ~/.ssh/config 中配置的:
-o
ProxyCommand
$ cat ~/.ssh/config Host myserver HostName xxx.xxx.xxx.xxx ProxyCommand nc -X 5 -x 127.0.0.1:1086 %h %p Port 22 User root IdentityFile ~/.ssh/my_id_rsa
可以给走代理的 Host 取一个别名例如 myserver-proxy,这样就可以自己选择要不要走代理连接 ssh 了。
myserver-proxy
参考链接:
The text was updated successfully, but these errors were encountered:
方便留给邮箱吗,我按你说的配置后,ssh -T git@github.com 测试还是不通
Sorry, something went wrong.
very helpful, thx.
补充一条 之前曾经用过brew安装过 nc 的会报错 可以输入命令which -a nc 发现有两个nc 把命令里面的nc换成系统自带的即可 ProxyCommand /usr/bin/nc -X 5 -x 127.0.0.1:1086 %h %p
which -a nc
ProxyCommand /usr/bin/nc -X 5 -x 127.0.0.1:1086 %h %p
可以选择使用 proxychains-ng 或者 proxychains.
No branches or pull requests
在上一篇《使用 root 用户登陆到腾讯云的主机》的结尾,我提到在特定网络环境下通过 ssh 访问服务器的连接会被屏蔽,这两天时不时的就会琢磨怎么解决这个问题,今天突然想到,ssh 能不能走代理访问到服务器?
谷歌了一番,发现真的可以……
当然,这样做的前提是得自备一个梯子。我在 macOS 用的是 ShadowsocksX-NG,在偏好设置里可以看到它在本地的 1086 端口开启了 Socks5 代理,那么通过代理访问服务器可以这么做:
连接成功后,可以运行
tac /var/log/auth.log | grep sshd
查看自己最近是从什么 IP 地址登陆的,你会发现登陆的 IP 和你在 ShadowsocksX-NG 中当前使用的服务器节点的 IP 是一样的。当然,
-o
后面的ProxyCommand
也是可以在 ~/.ssh/config 中配置的:可以给走代理的 Host 取一个别名例如
myserver-proxy
,这样就可以自己选择要不要走代理连接 ssh 了。参考链接:
The text was updated successfully, but these errors were encountered: