SFTP over gateway

2

1

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 ?

Alkalyne

Posted 2016-12-26T09:41:12.610

Reputation: 21

Why do you need to do sudo su - user2 to connect to the final server? – Martin Prikryl – 2016-12-26T10:14:15.823

That is very obscure setup. – Jakuje – 2016-12-26T10:17:58.387

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 – 2016-12-26T10:28:00.353

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 – 2016-12-26T10:31:53.123

Answers

0

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.

Martin Prikryl

Posted 2016-12-26T09:41:12.610

Reputation: 13 764

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 – 2016-12-26T10:24:48.140