Ten*_*ero 4 linux ssh unix shell scp
我想从我的个人电脑访问某个主机,但我必须先访问一个中间服务器,因为从公共互联网上看不到最终目的地。
问题是我必须执行以下操作才能访问最终主机。从我的电脑:
ssh username@server
Run Code Online (Sandbox Code Playgroud)
并输入密码。一旦我在那里:
ssh username2@finalhost
Run Code Online (Sandbox Code Playgroud)
并输入另一个密码。
这非常麻烦,特别是在执行scp
.时,因为我必须先将文件复制到中间服务器,然后才能将其复制到最终主机。
有没有办法使这个过程自动化,无论是 forssh
还是scp
命令?
如果您有OpenSSH 7.3或更高版本,则可以在 SSH 客户端配置中使用ProxyJump来指定跳转主机。
例如,编辑您的~/.ssh/config
并添加
Host finalhost
HostName finalhost.example.com
User username2
ProxyJump username@server
Run Code Online (Sandbox Code Playgroud)
现在ssh finalhost
还是scp file.txt finalhost:.
应该通过跳转主机。