开发者

script to SSH to a machine and do SCP

开发者 https://www.devze.com 2023-02-24 23:31 出处:网络
I have a scenario - I\'ll be logged in machineA. From there I need to ssh to machineB. From machineB I have to copy a file to machineC.

I have a scenario -

I'll be logged in machineA. From there I need to ssh to machineB. From machineB I have to copy a file to machineC.

I'm trying to do this in a single step:

[user@machineA]$ ssh user@machineB "scp /path/to/file root@machineC:"

But this command fails with error:

Host key verification failed. lost connection

Coul开发者_运维问答d someone help?

I need this for a real use.

I do development in machineA, so I will be coding and cross-compiling here. I need to copy my cross compiled binary to machineC for testing. However, direct connection machineA --> machineC won't work. I need to use machineB in between.

Also, machineB and machineA are mirrored; so i don't have to explicitly copy my file from machineA to machieB. I don't use machineB for development just because it is in remote site and will be slow.


Use the -t flag so that a tty is allocated. You need this so that you can be prompted for a password to machineC.

ssh -t user@machineB "scp /path/to/file root@machineC:/path"


Use this

scp -P PORT USER@IP_SERVER:filename .
0

精彩评论

暂无评论...
验证码 换一张
取 消