Seamless SFTP tunneling / jump boxSSH tunnel hangingWhy is my ssh connection unauthorized although I have updated my key on the remote machine?SSH tunneling via few hostsHow to set up chrooted and non-chrooted sftp?SSH console login working but SFTP does not, why?SSH pageant not workingsshd_selinux_copy_context: getcon failed with No such file or directory (SFTP from Windows to a chrooted account)Why is my SSH connection being closed immediately after pubkey auth succeeds?SSH Configuration Help / Can't tunnelpasswordless ssh to localhost in Ubuntu 16.04

Watching something be written to a file live with tail

What is the word for reserving something for yourself before others do?

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

Rock identification in KY

How to format long polynomial?

How does quantile regression compare to logistic regression with the variable split at the quantile?

What does the "remote control" for a QF-4 look like?

Perform and show arithmetic with LuaLaTeX

Why doesn't H₄O²⁺ exist?

NMaximize is not converging to a solution

How old can references or sources in a thesis be?

Replacing matching entries in one column of a file by another column from a different file

How do I deal with an unproductive colleague in a small company?

What is a clear way to write a bar that has an extra beat?

Is it possible to run Internet Explorer on OS X El Capitan?

Why do I get two different answers for this counting problem?

Does an object always see its latest internal state irrespective of thread?

Is it unprofessional to ask if a job posting on GlassDoor is real?

Character reincarnated...as a snail

What are these boxed doors outside store fronts in New York?

tikz convert color string to hex value

What does it mean to describe someone as a butt steak?

How is it possible to have an ability score that is less than 3?

Doing something right before you need it - expression for this?



Seamless SFTP tunneling / jump box


SSH tunnel hangingWhy is my ssh connection unauthorized although I have updated my key on the remote machine?SSH tunneling via few hostsHow to set up chrooted and non-chrooted sftp?SSH console login working but SFTP does not, why?SSH pageant not workingsshd_selinux_copy_context: getcon failed with No such file or directory (SFTP from Windows to a chrooted account)Why is my SSH connection being closed immediately after pubkey auth succeeds?SSH Configuration Help / Can't tunnelpasswordless ssh to localhost in Ubuntu 16.04






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I'm trying to set up a way for users to connect to the same gateway server for SSH/SFTP (SFTP a priority, SSH nice to have) and have that gateway server route the users to private servers inside my network identified by username and the private host they want to reach. This has to be a seamless user experience, i.e - no special config file setup, no flags for command line sessions, and no special setting in UI tools like Filezilla.



What I managed to do so far is add this block to my sshd_config file in the gateway server:



Match User someuser 
ForceCommand sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


Now this works great when I'm doing this from a client machine:



ssh -i id_rsa someuser@gateway_server_machine



it will trigger the ForceCommand and give me an SFTP session to the some_other_server machine.



BUT



When I do sftp -i id_rsa someuser@gateway_server_machine



the connection hangs and eventually terminated.



so, the sftp doesn't give anything even with verbose - just hangs there - but this is what I get from the server side:



debug1: subsystem: internal-sftp
Starting session: forced-command (config) 'sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server ' for someuser from 10.16.2.149 port 58822 id 0


on SSH I get:



Starting session: forced-command (config) 'sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server ' on pts/1 for someuser from 10.16.2.149 port 33550 id 0
debug1: Setting controlling tty using TIOCSCTTY.


I need to figure out what am I doing wrong here, or if there is a better way to provide this kind of connection to my users.










share|improve this question









New contributor




Itai Malek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    3















    I'm trying to set up a way for users to connect to the same gateway server for SSH/SFTP (SFTP a priority, SSH nice to have) and have that gateway server route the users to private servers inside my network identified by username and the private host they want to reach. This has to be a seamless user experience, i.e - no special config file setup, no flags for command line sessions, and no special setting in UI tools like Filezilla.



    What I managed to do so far is add this block to my sshd_config file in the gateway server:



    Match User someuser 
    ForceCommand sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


    Now this works great when I'm doing this from a client machine:



    ssh -i id_rsa someuser@gateway_server_machine



    it will trigger the ForceCommand and give me an SFTP session to the some_other_server machine.



    BUT



    When I do sftp -i id_rsa someuser@gateway_server_machine



    the connection hangs and eventually terminated.



    so, the sftp doesn't give anything even with verbose - just hangs there - but this is what I get from the server side:



    debug1: subsystem: internal-sftp
    Starting session: forced-command (config) 'sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server ' for someuser from 10.16.2.149 port 58822 id 0


    on SSH I get:



    Starting session: forced-command (config) 'sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server ' on pts/1 for someuser from 10.16.2.149 port 33550 id 0
    debug1: Setting controlling tty using TIOCSCTTY.


    I need to figure out what am I doing wrong here, or if there is a better way to provide this kind of connection to my users.










    share|improve this question









    New contributor




    Itai Malek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      3












      3








      3


      1






      I'm trying to set up a way for users to connect to the same gateway server for SSH/SFTP (SFTP a priority, SSH nice to have) and have that gateway server route the users to private servers inside my network identified by username and the private host they want to reach. This has to be a seamless user experience, i.e - no special config file setup, no flags for command line sessions, and no special setting in UI tools like Filezilla.



      What I managed to do so far is add this block to my sshd_config file in the gateway server:



      Match User someuser 
      ForceCommand sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


      Now this works great when I'm doing this from a client machine:



      ssh -i id_rsa someuser@gateway_server_machine



      it will trigger the ForceCommand and give me an SFTP session to the some_other_server machine.



      BUT



      When I do sftp -i id_rsa someuser@gateway_server_machine



      the connection hangs and eventually terminated.



      so, the sftp doesn't give anything even with verbose - just hangs there - but this is what I get from the server side:



      debug1: subsystem: internal-sftp
      Starting session: forced-command (config) 'sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server ' for someuser from 10.16.2.149 port 58822 id 0


      on SSH I get:



      Starting session: forced-command (config) 'sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server ' on pts/1 for someuser from 10.16.2.149 port 33550 id 0
      debug1: Setting controlling tty using TIOCSCTTY.


      I need to figure out what am I doing wrong here, or if there is a better way to provide this kind of connection to my users.










      share|improve this question









      New contributor




      Itai Malek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I'm trying to set up a way for users to connect to the same gateway server for SSH/SFTP (SFTP a priority, SSH nice to have) and have that gateway server route the users to private servers inside my network identified by username and the private host they want to reach. This has to be a seamless user experience, i.e - no special config file setup, no flags for command line sessions, and no special setting in UI tools like Filezilla.



      What I managed to do so far is add this block to my sshd_config file in the gateway server:



      Match User someuser 
      ForceCommand sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


      Now this works great when I'm doing this from a client machine:



      ssh -i id_rsa someuser@gateway_server_machine



      it will trigger the ForceCommand and give me an SFTP session to the some_other_server machine.



      BUT



      When I do sftp -i id_rsa someuser@gateway_server_machine



      the connection hangs and eventually terminated.



      so, the sftp doesn't give anything even with verbose - just hangs there - but this is what I get from the server side:



      debug1: subsystem: internal-sftp
      Starting session: forced-command (config) 'sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server ' for someuser from 10.16.2.149 port 58822 id 0


      on SSH I get:



      Starting session: forced-command (config) 'sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server ' on pts/1 for someuser from 10.16.2.149 port 33550 id 0
      debug1: Setting controlling tty using TIOCSCTTY.


      I need to figure out what am I doing wrong here, or if there is a better way to provide this kind of connection to my users.







      ssh ssh-tunneling sftp






      share|improve this question









      New contributor




      Itai Malek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Itai Malek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 2 days ago







      Itai Malek













      New contributor




      Itai Malek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      Itai MalekItai Malek

      183




      183




      New contributor




      Itai Malek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Itai Malek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Itai Malek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes


















          1














          ForceCommand sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          The above will start SFTP client on the intermediate server with its textual interface. Your local SFTP client (sftp or any other) cannot talk to that. It needs binary SFTP protocol. That also explain why ssh seeming works as sftp client. But it does not. It just pipes the textual interface of the sftp client on the intermediate server.




          What you need is something like:



          ForceCommand ssh -s sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          That makes the (most) remote server start SFTP server (-s sftp) and the intermediate server to pipe the binary SFTP protocol to and back (ssh just pipes the binary input/output of remote sftp-server, the same way as in your setup the local ssh pipes textual input/output of intermediate sftp).




          But if you need both SFTP and SSH you will need to use Subsystem directive for SFTP, not ForceCommand:



          Subsystem sftp ssh -s sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          Or to avoid having to repeat the tunneling separately for SSH and SFTP, you can use SSH_ORIGINAL_COMMAND environment variable to decide whether to use -s sftp or not.



          If you actually know that the (most) remote SFTP server has OpenSSH too and the same path to sftp-server binary as the intermediate server, this should cover both SSH and SFTP:



          ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND





          share|improve this answer




















          • 1





            thank you ! that worked: ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND

            – Itai Malek
            2 days ago











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Itai Malek is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f510258%2fseamless-sftp-tunneling-jump-box%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          ForceCommand sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          The above will start SFTP client on the intermediate server with its textual interface. Your local SFTP client (sftp or any other) cannot talk to that. It needs binary SFTP protocol. That also explain why ssh seeming works as sftp client. But it does not. It just pipes the textual interface of the sftp client on the intermediate server.




          What you need is something like:



          ForceCommand ssh -s sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          That makes the (most) remote server start SFTP server (-s sftp) and the intermediate server to pipe the binary SFTP protocol to and back (ssh just pipes the binary input/output of remote sftp-server, the same way as in your setup the local ssh pipes textual input/output of intermediate sftp).




          But if you need both SFTP and SSH you will need to use Subsystem directive for SFTP, not ForceCommand:



          Subsystem sftp ssh -s sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          Or to avoid having to repeat the tunneling separately for SSH and SFTP, you can use SSH_ORIGINAL_COMMAND environment variable to decide whether to use -s sftp or not.



          If you actually know that the (most) remote SFTP server has OpenSSH too and the same path to sftp-server binary as the intermediate server, this should cover both SSH and SFTP:



          ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND





          share|improve this answer




















          • 1





            thank you ! that worked: ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND

            – Itai Malek
            2 days ago















          1














          ForceCommand sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          The above will start SFTP client on the intermediate server with its textual interface. Your local SFTP client (sftp or any other) cannot talk to that. It needs binary SFTP protocol. That also explain why ssh seeming works as sftp client. But it does not. It just pipes the textual interface of the sftp client on the intermediate server.




          What you need is something like:



          ForceCommand ssh -s sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          That makes the (most) remote server start SFTP server (-s sftp) and the intermediate server to pipe the binary SFTP protocol to and back (ssh just pipes the binary input/output of remote sftp-server, the same way as in your setup the local ssh pipes textual input/output of intermediate sftp).




          But if you need both SFTP and SSH you will need to use Subsystem directive for SFTP, not ForceCommand:



          Subsystem sftp ssh -s sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          Or to avoid having to repeat the tunneling separately for SSH and SFTP, you can use SSH_ORIGINAL_COMMAND environment variable to decide whether to use -s sftp or not.



          If you actually know that the (most) remote SFTP server has OpenSSH too and the same path to sftp-server binary as the intermediate server, this should cover both SSH and SFTP:



          ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND





          share|improve this answer




















          • 1





            thank you ! that worked: ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND

            – Itai Malek
            2 days ago













          1












          1








          1







          ForceCommand sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          The above will start SFTP client on the intermediate server with its textual interface. Your local SFTP client (sftp or any other) cannot talk to that. It needs binary SFTP protocol. That also explain why ssh seeming works as sftp client. But it does not. It just pipes the textual interface of the sftp client on the intermediate server.




          What you need is something like:



          ForceCommand ssh -s sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          That makes the (most) remote server start SFTP server (-s sftp) and the intermediate server to pipe the binary SFTP protocol to and back (ssh just pipes the binary input/output of remote sftp-server, the same way as in your setup the local ssh pipes textual input/output of intermediate sftp).




          But if you need both SFTP and SSH you will need to use Subsystem directive for SFTP, not ForceCommand:



          Subsystem sftp ssh -s sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          Or to avoid having to repeat the tunneling separately for SSH and SFTP, you can use SSH_ORIGINAL_COMMAND environment variable to decide whether to use -s sftp or not.



          If you actually know that the (most) remote SFTP server has OpenSSH too and the same path to sftp-server binary as the intermediate server, this should cover both SSH and SFTP:



          ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND





          share|improve this answer















          ForceCommand sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          The above will start SFTP client on the intermediate server with its textual interface. Your local SFTP client (sftp or any other) cannot talk to that. It needs binary SFTP protocol. That also explain why ssh seeming works as sftp client. But it does not. It just pipes the textual interface of the sftp client on the intermediate server.




          What you need is something like:



          ForceCommand ssh -s sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          That makes the (most) remote server start SFTP server (-s sftp) and the intermediate server to pipe the binary SFTP protocol to and back (ssh just pipes the binary input/output of remote sftp-server, the same way as in your setup the local ssh pipes textual input/output of intermediate sftp).




          But if you need both SFTP and SSH you will need to use Subsystem directive for SFTP, not ForceCommand:



          Subsystem sftp ssh -s sftp -i /home/someuser/.ssh/id_rsa someuser@some_other_server


          Or to avoid having to repeat the tunneling separately for SSH and SFTP, you can use SSH_ORIGINAL_COMMAND environment variable to decide whether to use -s sftp or not.



          If you actually know that the (most) remote SFTP server has OpenSSH too and the same path to sftp-server binary as the intermediate server, this should cover both SSH and SFTP:



          ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago

























          answered 2 days ago









          Martin PrikrylMartin Prikryl

          400213




          400213







          • 1





            thank you ! that worked: ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND

            – Itai Malek
            2 days ago












          • 1





            thank you ! that worked: ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND

            – Itai Malek
            2 days ago







          1




          1





          thank you ! that worked: ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND

          – Itai Malek
          2 days ago





          thank you ! that worked: ForceCommand ssh -i /home/someuser/.ssh/id_rsa someuser@some_other_server $SSH_ORIGINAL_COMMAND

          – Itai Malek
          2 days ago










          Itai Malek is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Itai Malek is a new contributor. Be nice, and check out our Code of Conduct.












          Itai Malek is a new contributor. Be nice, and check out our Code of Conduct.











          Itai Malek is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f510258%2fseamless-sftp-tunneling-jump-box%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

          Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

          NetworkManager fails with “Could not find source connection”Trouble connecting to VPN using network-manager, while command line worksHow can I be notified about state changes to a VPN adapterBacktrack 5 R3 - Refuses to connect to VPNFeed all traffic through OpenVPN for a specific network namespace onlyRun daemon on startup in Debian once openvpn connection establishedpfsense tcp connection between openvpn and lan is brokenInternet connection problem with web browsers onlyWhy does NetworkManager explicitly support tun/tap devices?Browser issues with VPNTwo IP addresses assigned to the same network card - OpenVPN issues?Cannot connect to WiFi with nmcli, although secrets are provided