Issues with using Jump Host

荒凉一梦 提交于 2019-12-10 12:23:55

问题


How do I transfer a file from my local machine to a remote host to which I need to get through a jump host? These are the steps I follow to connect to the remote host

1. ssh myname@jump-host
2. enter password
3. sudo su - another-random-name
4. ssh name@remote-host

Now I want to transfer a file from my local machine to the remote-host. How would I achieve this? I have already tried scp -oProxyCommand but I don't quite know where I should include step 3 as part of this command?


回答1:


Use port forwarding to get third host ssh port on your localhost, in this way:

ssh -L 2222:remote-host:22 myname@jump-host

then (on another tab/shell on first host):

scp -P 2222 file myname@localhost:

will copy directly to remote host.




回答2:


On the jump host under another-random-name run

ssh -L 2222:remote-host:22 myname@jump-host

then on your local computer you can run

scp -P 2222 file name@jump-host:

SCP will try to connect to jump-host, while in fact this connection will be forwarded to jump-host. And will use name as it is connecting to remote-host. You are probably still facing problem with certificate for another-random-user. You can either create certificate on your machine for your-local-user and put public key on remote-host in user allowed keys.



来源:https://stackoverflow.com/questions/44756106/issues-with-using-jump-host

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!