美文网首页
ssh ProxyJump 通过代理机跳转内网

ssh ProxyJump 通过代理机跳转内网

作者: 癞痢头 | 来源:发表于2021-09-07 18:15 被阅读0次

    ssh 通过代理机跳转内网

    ssh 命令有一种简单的方法来利用跳板主机通过单个命令连接到远程主机。 ssh 可以使用 ProxyJump 创建初始和第二个连接,而不是首先通过 SSH 连接到跳板主机,然后在跳板上使用 ssh 连接到远程主机。

    ProxyJump 或 -J 标志是在 ssh 7.3 版中引入的。要使用它,请在 -J 标志后指定要连接的跳板机,以及远程主机:

    语法规则如下

    1. 通过 jump-host 登陆 remote-host
    $ ssh -J <jump-host> <remote-host>
    
    1. 如果主机端口不同, 可使用如下命令
    $ ssh -J user@<jump-host:port> <user@remote:port>
    
    1. scp 使用跳板机上传文件的命令
    $ scp -o 'ProxyJump jump.host' myfile.txt remote.host:/my/dir
    

    如果需要多个跳转, 多个跳板机使用逗号隔开

    ssh -J <jump.host1>,<jump.host2> <remote>
    

    另外另种方式是:

    1. ssh tunnel
    2. ProxyCommand

    相关文章

      网友评论

          本文标题:ssh ProxyJump 通过代理机跳转内网

          本文链接:https://www.haomeiwen.com/subject/xwepwltx.html