I need to connect to a remote machine which then can connect to another one and download a file from there. To read the file, I would do:
ssh REMOTEMACHINE
- Enter password
ssh HIDDENMACHINE
- Authenticates via private key on REMOTEMACHINE
less my_file.log
I want to download that file directly instead of viewing it in shell. I found that scp supports proxy command and it works except it cannot do the second hop because it does not read the private key from REMOTEMACHINE:~/.ssh/.
This is my command:
scp -oProxyJump=REMOTEMACHINE HIDDENMACHINE:my_file.log ./my_file.log
And the output is:
someuser@REMOTEMACHINE's password: *******
The authenticity of host 'HIDDENMACHINE (<no hostip for proxy command>)' can't be established.
ED25519 key fingerprint is SHA256:XXXXXX.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'HIDDENMACHINE' (ED25519) to the list of known hosts.
someuser@HIDDENMACHINE: Permission denied (publickey).
I was previously doing this programmatically using a ssh library, and my approach then was to first grab the private key from REMOTEMACHINE. Unfortunately the ssh library is bugged and not a suitable solution for downloading multiple files.