1

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

Could 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.

Mat
  • 195,986
  • 40
  • 382
  • 396
m.divya.mohan
  • 2,181
  • 4
  • 21
  • 32

2 Answers2

5

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"
dogbane
  • 254,755
  • 72
  • 386
  • 405
0

Use this

scp -P PORT USER@IP_SERVER:filename .
JellyBelly
  • 2,443
  • 2
  • 20
  • 41