admin管理员组

文章数量:1794759

mac

mac

mac-ProxyCommand 代理

内网进不去,但是想看生产的内容怎么办

前提是要有一台本地能ssh的机器 这台机器要和内网打通

在本地

ssh-keygen -t rsa 

到跳板机

vim .ssh/authorized_keys 
添加本地的public key

去跳板机做跳板的用户目录 例如root

 ssh-keygen -t rsa 

然后在跳板机ssh root@1x.9x.1x.2x。输入密码登录下

安装ProxyCommand

brew install proxychains-ng

配置

在~/.ssh/config 添加
Host dxx.sxx-bastionhostname 54.65.xx.2xxPort 18330User ec2-user
Host dxx.sxx-web1hostname 10.0.x.xxProxyCommand ssh dxx.sxx-bastion -W %h:%pUser ubuntu例如# jd_test
Host one-machine //要叫的名字
HostName 1x.9x.1x.2x //服务器地址
# 1x.9x.1x.2x对应的email或者用户名
User root //用户
#PreferredAuthentications publickey
# 1x.9x.1x.2x对应的私钥
IdentityFile ~/.ssh/id_rsa //跳板机的私钥
ForwardAgent yesHost 161-machine //最终代理到的机器
HostName 17x.2x.1x.1x
User zhangsan //登录这台机器的用户名
Port 22
ProxyCommand ssh -q -W %h:%p noah-machine

ps:
%h 表示 hostname
%p 表示 port

主备好上面 在本地mac配置

vim /etc/hosts1x.9x.1x.2x one-machine
17x.2x.1x.1x 161-machine

然后节能直接登陆了。在本地

因为跳板机家了publickey 不用密码就能登陆 在登陆目标机器直接输入密码就可以了

本文标签: mac