ssh ProxyCommand免密码

阅读量: searchstar 2022-03-13 21:00:48
Categories: Tags:

假设自己的电脑是A,跳板机是B,要访问的机器是C。首先在A上生成ssh密钥,然后把公钥放到B和C上。然后在A机器上的.ssh/config里进行如下配置:

Host B
        HostName 在A视角下B的IP
        Port 在A视角下B的端口
        User B上的用户名
        IdentityFile 本地的ssh私钥路径

Host C
        ProxyCommand ssh -W 在B视角下C的IP:在B视角下C的端口 B
        User C上的用户名
        IdentityFile 本地的ssh私钥路径

然后在A机器上直接ssh C即可免密码登录C。

参考:

内网穿透

https://serverfault.com/questions/906298/ssh-proxycommand-with-same-password