I'm trying to connect to a server (with SFTP) through a gateway, but I can't find a solution with SSH tunnelling. This is how it should work :

  • Connect to ssh gatewayserver using user1/password1
  • sudo su - user2 (only command I can execute using sudo)
  • ssh finalserver (With private key of user2)
  • sudo su - finaluser

And I can't copy user2 private key anywhere since it will be considered as unsecure

Do you have any idea how can configure an SFTP/SCP client (using Mobaxterm, Putty, Winscp or another client) following these steps ?

  • Why do you need to do sudo su - user2 to connect to the final server? – Martin Prikryl Dec 26 '16 at 10:14
  • That is very obscure setup. – Jakuje Dec 26 '16 at 10:17
  • First sudo is needed to use the privatekey stored on user2 account to connect to final server Second sudo is because we can only connect to final server using user2 (can't do finaluser@finalserver) and then sudo to finaluser – Alkalyne Dec 26 '16 at 10:28
  • But the private key is (likely) for OpenSSH client. So that setup allows you to use the OpenSSH client on the gateway server only. You cannot wonder, that you would not be able to use any other client. – Martin Prikryl Dec 26 '16 at 10:31

WinSCP supports tunneling though other SSH server natively.

See the Tunnel page of its Advanced site settings dialog.

Tunnel page

For other clients, you can setup the tunnel using PuTTY and connect though it.

See my guide for tunneling SFTP/SCP session.

  • Yes, I tried this, but it will not work since I need to sudo to user2 on gateway server in order to connect to finalserver. Only way using this seems to copy the privatekey stored on gatewayserver for user2 on my computer, but the security policy does not allow me to do this. – Alkalyne Dec 26 '16 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.