Passing multiple files through stdin (over ssh)Remote desktop (KDE) over SSH reverse tunnelMonitor via SSH and execute local script upon change detectionCorrectly parse arguments in script behaving like a shell called through SSHtransfer many similar files over sshssh some commands through (a variable amount of) intermediary hopsHow can I pass two files through ssh?How to pass data through existing SSH connection?Executing `sh -c` script through SSH (passing arguments safely and sanely)SCP copy through SSH not working - permission denied and stdin is not a ttyssh routing between multiple linux system containers transparently

A deadly disease, 95% of the population dead, suppresses or alters memory in unpredictable ways

Russian equivalents of "no love lost"

Where does "0 packages can be updated." come from?

Should I give professor gift at the beginning of my PhD?

My coworkers think I had a long honeymoon. Actually I was diagnosed with cancer. How do I talk about it?

How do governments keep track of their issued currency?

PhD - Well known professor or well known school?

Frame failure sudden death?

Preventing Employees from either switching to Competitors or Opening Their Own Business

What risks are there when you clear your cookies instead of logging off?

How did students remember what to practise between lessons without any sheet music?

How water is heavier than petrol eventhough its molecular weight less than petrol?

What can I, as a user, do about offensive reviews in App Store?

Different pedals/effects for low strings/notes than high

Words that signal future content

How to chain Python function calls so the behaviour is as follows

Trapping Rain Water

Arriving at the same result with the opposite hypotheses

What can plausibly explain many of my very long and low-tech bridges?

Payment instructions allegedly from HomeAway look fishy to me

Winning Strategy for the Magician and his Apprentice

Was the Tamarian language in "Darmok" inspired by Jack Vance's "The Asutra"?

Implement Homestuck's Catenative Doomsday Dice Cascader

Cross-dimension teleportation using command block or datapack?



Passing multiple files through stdin (over ssh)


Remote desktop (KDE) over SSH reverse tunnelMonitor via SSH and execute local script upon change detectionCorrectly parse arguments in script behaving like a shell called through SSHtransfer many similar files over sshssh some commands through (a variable amount of) intermediary hopsHow can I pass two files through ssh?How to pass data through existing SSH connection?Executing `sh -c` script through SSH (passing arguments safely and sanely)SCP copy through SSH not working - permission denied and stdin is not a ttyssh routing between multiple linux system containers transparently






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








3















I have a program on a remote host, whose execution I need to automate. The command execute that program, on the same machine, looks something like this:



/path/to/program -a file1.txt -b file2.txt


In this case, file1.txt and file2.txt are used for entirely different things within the program, so I can't just cat them together. However, in my case, the file1.txt and file2.txt that I want to pass into the program exist only on my device, not on the host where I need to execute the program. I know that I can feed at least one file through SSH by passing it through stdin:



cat file1.txt | ssh host.name /path/to/program -a /dev/stdin -b file2.txt


but, since I'm not allowed to store files on the host, I need a way to get the file2.txt over there as well. I'm thinking it might be possible through abuse of environment variables and creative use of cat and sed together, but I don't know the tools well enough to understand how I would use them to accomplish this. Is it doable, and how?










share|improve this question







New contributor



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














  • 1





    catand sed are not the solution here.

    – Slyx
    8 hours ago












  • Probably I'd be able to mount, but given proxies and security constraints I'm not sure I'd be able to get away with it.

    – Green Cloak Guy
    8 hours ago












  • Do you have the permission in the remote machine to mount an ssh folder?

    – Slyx
    8 hours ago











  • if you can open an ssh session from the remote machine to your local one, so there's no issue at the network level to mount an SSH folder.

    – Slyx
    8 hours ago











  • Can you do forwardings? What systems and shells do you have at the local and the remote end?

    – mosvy
    6 hours ago

















3















I have a program on a remote host, whose execution I need to automate. The command execute that program, on the same machine, looks something like this:



/path/to/program -a file1.txt -b file2.txt


In this case, file1.txt and file2.txt are used for entirely different things within the program, so I can't just cat them together. However, in my case, the file1.txt and file2.txt that I want to pass into the program exist only on my device, not on the host where I need to execute the program. I know that I can feed at least one file through SSH by passing it through stdin:



cat file1.txt | ssh host.name /path/to/program -a /dev/stdin -b file2.txt


but, since I'm not allowed to store files on the host, I need a way to get the file2.txt over there as well. I'm thinking it might be possible through abuse of environment variables and creative use of cat and sed together, but I don't know the tools well enough to understand how I would use them to accomplish this. Is it doable, and how?










share|improve this question







New contributor



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














  • 1





    catand sed are not the solution here.

    – Slyx
    8 hours ago












  • Probably I'd be able to mount, but given proxies and security constraints I'm not sure I'd be able to get away with it.

    – Green Cloak Guy
    8 hours ago












  • Do you have the permission in the remote machine to mount an ssh folder?

    – Slyx
    8 hours ago











  • if you can open an ssh session from the remote machine to your local one, so there's no issue at the network level to mount an SSH folder.

    – Slyx
    8 hours ago











  • Can you do forwardings? What systems and shells do you have at the local and the remote end?

    – mosvy
    6 hours ago













3












3








3








I have a program on a remote host, whose execution I need to automate. The command execute that program, on the same machine, looks something like this:



/path/to/program -a file1.txt -b file2.txt


In this case, file1.txt and file2.txt are used for entirely different things within the program, so I can't just cat them together. However, in my case, the file1.txt and file2.txt that I want to pass into the program exist only on my device, not on the host where I need to execute the program. I know that I can feed at least one file through SSH by passing it through stdin:



cat file1.txt | ssh host.name /path/to/program -a /dev/stdin -b file2.txt


but, since I'm not allowed to store files on the host, I need a way to get the file2.txt over there as well. I'm thinking it might be possible through abuse of environment variables and creative use of cat and sed together, but I don't know the tools well enough to understand how I would use them to accomplish this. Is it doable, and how?










share|improve this question







New contributor



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











I have a program on a remote host, whose execution I need to automate. The command execute that program, on the same machine, looks something like this:



/path/to/program -a file1.txt -b file2.txt


In this case, file1.txt and file2.txt are used for entirely different things within the program, so I can't just cat them together. However, in my case, the file1.txt and file2.txt that I want to pass into the program exist only on my device, not on the host where I need to execute the program. I know that I can feed at least one file through SSH by passing it through stdin:



cat file1.txt | ssh host.name /path/to/program -a /dev/stdin -b file2.txt


but, since I'm not allowed to store files on the host, I need a way to get the file2.txt over there as well. I'm thinking it might be possible through abuse of environment variables and creative use of cat and sed together, but I don't know the tools well enough to understand how I would use them to accomplish this. Is it doable, and how?







ssh io-redirection






share|improve this question







New contributor



Green Cloak Guy 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



Green Cloak Guy 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






New contributor



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








asked 8 hours ago









Green Cloak GuyGreen Cloak Guy

1163




1163




New contributor



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




New contributor




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









  • 1





    catand sed are not the solution here.

    – Slyx
    8 hours ago












  • Probably I'd be able to mount, but given proxies and security constraints I'm not sure I'd be able to get away with it.

    – Green Cloak Guy
    8 hours ago












  • Do you have the permission in the remote machine to mount an ssh folder?

    – Slyx
    8 hours ago











  • if you can open an ssh session from the remote machine to your local one, so there's no issue at the network level to mount an SSH folder.

    – Slyx
    8 hours ago











  • Can you do forwardings? What systems and shells do you have at the local and the remote end?

    – mosvy
    6 hours ago












  • 1





    catand sed are not the solution here.

    – Slyx
    8 hours ago












  • Probably I'd be able to mount, but given proxies and security constraints I'm not sure I'd be able to get away with it.

    – Green Cloak Guy
    8 hours ago












  • Do you have the permission in the remote machine to mount an ssh folder?

    – Slyx
    8 hours ago











  • if you can open an ssh session from the remote machine to your local one, so there's no issue at the network level to mount an SSH folder.

    – Slyx
    8 hours ago











  • Can you do forwardings? What systems and shells do you have at the local and the remote end?

    – mosvy
    6 hours ago







1




1





catand sed are not the solution here.

– Slyx
8 hours ago






catand sed are not the solution here.

– Slyx
8 hours ago














Probably I'd be able to mount, but given proxies and security constraints I'm not sure I'd be able to get away with it.

– Green Cloak Guy
8 hours ago






Probably I'd be able to mount, but given proxies and security constraints I'm not sure I'd be able to get away with it.

– Green Cloak Guy
8 hours ago














Do you have the permission in the remote machine to mount an ssh folder?

– Slyx
8 hours ago





Do you have the permission in the remote machine to mount an ssh folder?

– Slyx
8 hours ago













if you can open an ssh session from the remote machine to your local one, so there's no issue at the network level to mount an SSH folder.

– Slyx
8 hours ago





if you can open an ssh session from the remote machine to your local one, so there's no issue at the network level to mount an SSH folder.

– Slyx
8 hours ago













Can you do forwardings? What systems and shells do you have at the local and the remote end?

– mosvy
6 hours ago





Can you do forwardings? What systems and shells do you have at the local and the remote end?

– mosvy
6 hours ago










5 Answers
5






active

oldest

votes


















2














If the files given as arguments to your program are text files, and you're able to control their content (you know a line which doesn't occur inside them), you can use multiple here-documents:




echo "cat /dev/fd/3 3<<'EOT' /dev/fd/4 4<<'EOT' /dev/fd/5 5<<'EOT'"
cat file1
echo EOT
cat file2
echo EOT
cat file3
echo EOT
| ssh user@host sh


Here cat is a sample command which takes filenames as arguments. It could be instead:



echo "/path/to/prog -a /dev/fd/3 3<<'EOT' -b /dev/fd/4 4<<'EOT'


Replace each EOT with something that doesn't occur in each of the files, respectively.






share|improve this answer























  • This approach is quite clever! If the files are not text, you could encode/decode them with something like base64 or even good ol' uuencode... Very nice!

    – filbranden
    2 hours ago


















1














If you can set a TCP listener (can be a higher port), then you could use a second SSH session to establish the second input source with nc.



Example:



There's this script on the server (~/script.bash):



#!/usr/bin/env bash
cat "$1" | tr a 1
nc localhost "$2" | tr '[:lower:]' '[:upper:]'


And there are these two files locally:



$ cat a 
aaa
aaa
aaa
$ cat b
bbb
bbb
bbb


Now first start the second source ($serv is the server):



ssh "$serv" nc -l -p 2222 -q1 <b &


And run the command proper:



$ ssh "$serv" ./script.bash - 2222 <a
111
111
111
BBB
BBB
BBB
[1]+ Done ssh "$serv" nc -l -p 2222 -q1 < b





share|improve this answer
































    0














    Unfortunately there's not a great way to do this directly, since the ssh client will only pass the three file descriptors (stdin, stdout and stderr) to the server and it doesn't have provisions to pass additional file descriptors (which would be helpful for this particular use case.)



    (Also note that the SSH protocol has provisions to pass additional file descriptors, only the ssh client doesn't implement a way to use that feature. Theoretically, extending the client with a patch would be enough to expose this feature.)



    One hacky way to accomplish what you're looking for is to use file descriptor 2 (the stderr file descriptor) to pass the second file. Something like:



    $ ssh remote.name 
    /path/to/program -a /dev/stdin -b /dev/stderr
    <file1.txt 2<file2.txt


    This should work, it just might cause an issue if program tries to write to stderr. You can work around that by re-juggling the file descriptors on the remote end before you run program. You can move file2.txt to file descriptor 3 and re-open stderr to mirror stdout:



    $ ssh remote.name 
    /path/to/program -a /dev/stdin -b /dev/fd/3
    '3<&2' '2>&1'
    <file1.txt 2<file2.txt





    share|improve this answer























    • I haven't really tested this (typing on a phone) but at least in theory I'd expect it to work. Let me know if for some reason it doesn't. Cheers!

      – filbranden
      6 hours ago











    • That won't work at all. Not even with a hacked ssh. AFAIK stderr doesn't use a separate channel, but some special kind of message. But yes, being able to access ssh channels as pipes or unnamed unix domain sockets (instead of having to do socket forwardings) would be great, it just doesn't seem to be possible in any kind or shape.

      – mosvy
      6 hours ago












    • @mosvy, fd 0, 1 and 2 on the remote command will be 3 different pipes. The data travels through 3 different channels multiplexed in the ssh connection, but those are uni-directional (from client to sever for fd 0 and from server to client for 1 and 2), so even on systems where pipes are bidirectional, that won't work. On Linux, openening /dev/stderr in readonly mode gives on the other end of the pipe, so it would never work either.

      – Stéphane Chazelas
      6 hours ago











    • Note that the last one assumes the login shell of the user on remote.name is Bourne-like (3<&2 is a Bourne shell operator, and sshd runs the login shell of the user to interpret the command sent by the client)

      – Stéphane Chazelas
      6 hours ago







    • 1





      @StéphaneChazelas Nope, a single ssh channel is used for stdin/stdout/stderr, and the stderr data is transferred via SSH_MSG_CHANNEL_EXTENDED_DATA messages with the type set to SSH_EXTENDED_DATA_STDERR. You can read the whole thing here

      – mosvy
      5 hours ago



















    0














    If you're allowed to forward ports over ssh, and you have access to wget on the remote machine and to busybox on the local machine, you can do something like:



    mkdir /tmp/test; cd /tmp/test
    echo 1st_file > 1st_file
    echo 2nd_file > 2nd_file

    busybox httpd -f -p 127.0.0.1:11080 &
    ssh USER@HOST -R 10080:127.0.0.1:11080 '
    cat <(wget -q -O- http://localhost:10080/1st_file)
    <(wget -q -O- http://localhost:10080/2nd_file)
    '
    kill $!


    (using cat as an example program which takes two file arguments).



    Only the ability to forward ports via -R is essential -- instead of doing http, you can use other methods (2 netcats and 2 forwardings, /dev/tcp/ in bash on the remote side, etc). But convincing a netcat without the -N option to close the connection proved to be much messier than I though.



    There may be ways to replace the <(...) process subtitutions if the shell on the remote machine isn't ksh- or bash- like.



    All in all, this isn't too great -- better knowledge about the exact system/shells/config/permissions (which you haven't provided) could allow for smarter solutions.






    share|improve this answer
































      0














      Perhaps not exactly what you want... But maybe consider sending a tarball through the pipe opened by ssh?



      You said that:




      I'm not allowed to store files on the host.




      It's possible that you don't have a writable home directory or other convenient location to store files long term, but I'd say it's unlikely you don't have any writable location, even if a temporary tmpfs that will be made available only for your particular connection.



      Many programs (and even libc routines) require a writable /tmp, so it's very likely one will be available to you.



      Then you could use a script that will unpack the tarball into a temporary directory, run your program and cleanup through the ssh connection.



      Something like:



      $ tar cf - file1.txt file2.txt |
      ssh host.name '
      set -e
      tmpdir=$(mktemp -d -t tmp.XXXXXXXXXX)
      cleanup () rm -rf "$tmpdir";
      trap cleanup EXIT
      cd "$tmpdir"
      tar xf -
      /path/to/program -a file1.txt -b file2.txt
      '


      This might need some extra care with file paths and there are some corner cases to consider (test for them), but the general approach should work.



      If no writable directory is available, a possible approach would be to modify program to take a tarball as single input and unpack its contents to memory. For instance, if program is a Python script, then using the built-in tarfile module would easily accomplish something like that.






      share|improve this answer


















      • 1





        Even without going through the trouble of tarballing it - I've decided more or less to just write a file to /tmp/ and use it directly.

        – Green Cloak Guy
        2 hours ago











      • The tarball approach has some advantages, as you use a single ssh connection (no need to test for success/failure) and multiple concurrent runs are not likely to run into each other (use and/or delete files in /tmp meant for separate runs.) But I think that's the best you'll get from ssh as it exists now. Good luck!

        – filbranden
        2 hours ago






      • 1





        @GreenCloakGuy So after all, you can store files on the server just fine. Please modify the question accordingly.

        – mosvy
        2 hours 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
      );



      );






      Green Cloak Guy 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%2f522637%2fpassing-multiple-files-through-stdin-over-ssh%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      If the files given as arguments to your program are text files, and you're able to control their content (you know a line which doesn't occur inside them), you can use multiple here-documents:




      echo "cat /dev/fd/3 3<<'EOT' /dev/fd/4 4<<'EOT' /dev/fd/5 5<<'EOT'"
      cat file1
      echo EOT
      cat file2
      echo EOT
      cat file3
      echo EOT
      | ssh user@host sh


      Here cat is a sample command which takes filenames as arguments. It could be instead:



      echo "/path/to/prog -a /dev/fd/3 3<<'EOT' -b /dev/fd/4 4<<'EOT'


      Replace each EOT with something that doesn't occur in each of the files, respectively.






      share|improve this answer























      • This approach is quite clever! If the files are not text, you could encode/decode them with something like base64 or even good ol' uuencode... Very nice!

        – filbranden
        2 hours ago















      2














      If the files given as arguments to your program are text files, and you're able to control their content (you know a line which doesn't occur inside them), you can use multiple here-documents:




      echo "cat /dev/fd/3 3<<'EOT' /dev/fd/4 4<<'EOT' /dev/fd/5 5<<'EOT'"
      cat file1
      echo EOT
      cat file2
      echo EOT
      cat file3
      echo EOT
      | ssh user@host sh


      Here cat is a sample command which takes filenames as arguments. It could be instead:



      echo "/path/to/prog -a /dev/fd/3 3<<'EOT' -b /dev/fd/4 4<<'EOT'


      Replace each EOT with something that doesn't occur in each of the files, respectively.






      share|improve this answer























      • This approach is quite clever! If the files are not text, you could encode/decode them with something like base64 or even good ol' uuencode... Very nice!

        – filbranden
        2 hours ago













      2












      2








      2







      If the files given as arguments to your program are text files, and you're able to control their content (you know a line which doesn't occur inside them), you can use multiple here-documents:




      echo "cat /dev/fd/3 3<<'EOT' /dev/fd/4 4<<'EOT' /dev/fd/5 5<<'EOT'"
      cat file1
      echo EOT
      cat file2
      echo EOT
      cat file3
      echo EOT
      | ssh user@host sh


      Here cat is a sample command which takes filenames as arguments. It could be instead:



      echo "/path/to/prog -a /dev/fd/3 3<<'EOT' -b /dev/fd/4 4<<'EOT'


      Replace each EOT with something that doesn't occur in each of the files, respectively.






      share|improve this answer













      If the files given as arguments to your program are text files, and you're able to control their content (you know a line which doesn't occur inside them), you can use multiple here-documents:




      echo "cat /dev/fd/3 3<<'EOT' /dev/fd/4 4<<'EOT' /dev/fd/5 5<<'EOT'"
      cat file1
      echo EOT
      cat file2
      echo EOT
      cat file3
      echo EOT
      | ssh user@host sh


      Here cat is a sample command which takes filenames as arguments. It could be instead:



      echo "/path/to/prog -a /dev/fd/3 3<<'EOT' -b /dev/fd/4 4<<'EOT'


      Replace each EOT with something that doesn't occur in each of the files, respectively.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered 2 hours ago









      mosvymosvy

      12.4k11542




      12.4k11542












      • This approach is quite clever! If the files are not text, you could encode/decode them with something like base64 or even good ol' uuencode... Very nice!

        – filbranden
        2 hours ago

















      • This approach is quite clever! If the files are not text, you could encode/decode them with something like base64 or even good ol' uuencode... Very nice!

        – filbranden
        2 hours ago
















      This approach is quite clever! If the files are not text, you could encode/decode them with something like base64 or even good ol' uuencode... Very nice!

      – filbranden
      2 hours ago





      This approach is quite clever! If the files are not text, you could encode/decode them with something like base64 or even good ol' uuencode... Very nice!

      – filbranden
      2 hours ago













      1














      If you can set a TCP listener (can be a higher port), then you could use a second SSH session to establish the second input source with nc.



      Example:



      There's this script on the server (~/script.bash):



      #!/usr/bin/env bash
      cat "$1" | tr a 1
      nc localhost "$2" | tr '[:lower:]' '[:upper:]'


      And there are these two files locally:



      $ cat a 
      aaa
      aaa
      aaa
      $ cat b
      bbb
      bbb
      bbb


      Now first start the second source ($serv is the server):



      ssh "$serv" nc -l -p 2222 -q1 <b &


      And run the command proper:



      $ ssh "$serv" ./script.bash - 2222 <a
      111
      111
      111
      BBB
      BBB
      BBB
      [1]+ Done ssh "$serv" nc -l -p 2222 -q1 < b





      share|improve this answer





























        1














        If you can set a TCP listener (can be a higher port), then you could use a second SSH session to establish the second input source with nc.



        Example:



        There's this script on the server (~/script.bash):



        #!/usr/bin/env bash
        cat "$1" | tr a 1
        nc localhost "$2" | tr '[:lower:]' '[:upper:]'


        And there are these two files locally:



        $ cat a 
        aaa
        aaa
        aaa
        $ cat b
        bbb
        bbb
        bbb


        Now first start the second source ($serv is the server):



        ssh "$serv" nc -l -p 2222 -q1 <b &


        And run the command proper:



        $ ssh "$serv" ./script.bash - 2222 <a
        111
        111
        111
        BBB
        BBB
        BBB
        [1]+ Done ssh "$serv" nc -l -p 2222 -q1 < b





        share|improve this answer



























          1












          1








          1







          If you can set a TCP listener (can be a higher port), then you could use a second SSH session to establish the second input source with nc.



          Example:



          There's this script on the server (~/script.bash):



          #!/usr/bin/env bash
          cat "$1" | tr a 1
          nc localhost "$2" | tr '[:lower:]' '[:upper:]'


          And there are these two files locally:



          $ cat a 
          aaa
          aaa
          aaa
          $ cat b
          bbb
          bbb
          bbb


          Now first start the second source ($serv is the server):



          ssh "$serv" nc -l -p 2222 -q1 <b &


          And run the command proper:



          $ ssh "$serv" ./script.bash - 2222 <a
          111
          111
          111
          BBB
          BBB
          BBB
          [1]+ Done ssh "$serv" nc -l -p 2222 -q1 < b





          share|improve this answer















          If you can set a TCP listener (can be a higher port), then you could use a second SSH session to establish the second input source with nc.



          Example:



          There's this script on the server (~/script.bash):



          #!/usr/bin/env bash
          cat "$1" | tr a 1
          nc localhost "$2" | tr '[:lower:]' '[:upper:]'


          And there are these two files locally:



          $ cat a 
          aaa
          aaa
          aaa
          $ cat b
          bbb
          bbb
          bbb


          Now first start the second source ($serv is the server):



          ssh "$serv" nc -l -p 2222 -q1 <b &


          And run the command proper:



          $ ssh "$serv" ./script.bash - 2222 <a
          111
          111
          111
          BBB
          BBB
          BBB
          [1]+ Done ssh "$serv" nc -l -p 2222 -q1 < b






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 5 hours ago

























          answered 8 hours ago









          TomaszTomasz

          10.5k73372




          10.5k73372





















              0














              Unfortunately there's not a great way to do this directly, since the ssh client will only pass the three file descriptors (stdin, stdout and stderr) to the server and it doesn't have provisions to pass additional file descriptors (which would be helpful for this particular use case.)



              (Also note that the SSH protocol has provisions to pass additional file descriptors, only the ssh client doesn't implement a way to use that feature. Theoretically, extending the client with a patch would be enough to expose this feature.)



              One hacky way to accomplish what you're looking for is to use file descriptor 2 (the stderr file descriptor) to pass the second file. Something like:



              $ ssh remote.name 
              /path/to/program -a /dev/stdin -b /dev/stderr
              <file1.txt 2<file2.txt


              This should work, it just might cause an issue if program tries to write to stderr. You can work around that by re-juggling the file descriptors on the remote end before you run program. You can move file2.txt to file descriptor 3 and re-open stderr to mirror stdout:



              $ ssh remote.name 
              /path/to/program -a /dev/stdin -b /dev/fd/3
              '3<&2' '2>&1'
              <file1.txt 2<file2.txt





              share|improve this answer























              • I haven't really tested this (typing on a phone) but at least in theory I'd expect it to work. Let me know if for some reason it doesn't. Cheers!

                – filbranden
                6 hours ago











              • That won't work at all. Not even with a hacked ssh. AFAIK stderr doesn't use a separate channel, but some special kind of message. But yes, being able to access ssh channels as pipes or unnamed unix domain sockets (instead of having to do socket forwardings) would be great, it just doesn't seem to be possible in any kind or shape.

                – mosvy
                6 hours ago












              • @mosvy, fd 0, 1 and 2 on the remote command will be 3 different pipes. The data travels through 3 different channels multiplexed in the ssh connection, but those are uni-directional (from client to sever for fd 0 and from server to client for 1 and 2), so even on systems where pipes are bidirectional, that won't work. On Linux, openening /dev/stderr in readonly mode gives on the other end of the pipe, so it would never work either.

                – Stéphane Chazelas
                6 hours ago











              • Note that the last one assumes the login shell of the user on remote.name is Bourne-like (3<&2 is a Bourne shell operator, and sshd runs the login shell of the user to interpret the command sent by the client)

                – Stéphane Chazelas
                6 hours ago







              • 1





                @StéphaneChazelas Nope, a single ssh channel is used for stdin/stdout/stderr, and the stderr data is transferred via SSH_MSG_CHANNEL_EXTENDED_DATA messages with the type set to SSH_EXTENDED_DATA_STDERR. You can read the whole thing here

                – mosvy
                5 hours ago
















              0














              Unfortunately there's not a great way to do this directly, since the ssh client will only pass the three file descriptors (stdin, stdout and stderr) to the server and it doesn't have provisions to pass additional file descriptors (which would be helpful for this particular use case.)



              (Also note that the SSH protocol has provisions to pass additional file descriptors, only the ssh client doesn't implement a way to use that feature. Theoretically, extending the client with a patch would be enough to expose this feature.)



              One hacky way to accomplish what you're looking for is to use file descriptor 2 (the stderr file descriptor) to pass the second file. Something like:



              $ ssh remote.name 
              /path/to/program -a /dev/stdin -b /dev/stderr
              <file1.txt 2<file2.txt


              This should work, it just might cause an issue if program tries to write to stderr. You can work around that by re-juggling the file descriptors on the remote end before you run program. You can move file2.txt to file descriptor 3 and re-open stderr to mirror stdout:



              $ ssh remote.name 
              /path/to/program -a /dev/stdin -b /dev/fd/3
              '3<&2' '2>&1'
              <file1.txt 2<file2.txt





              share|improve this answer























              • I haven't really tested this (typing on a phone) but at least in theory I'd expect it to work. Let me know if for some reason it doesn't. Cheers!

                – filbranden
                6 hours ago











              • That won't work at all. Not even with a hacked ssh. AFAIK stderr doesn't use a separate channel, but some special kind of message. But yes, being able to access ssh channels as pipes or unnamed unix domain sockets (instead of having to do socket forwardings) would be great, it just doesn't seem to be possible in any kind or shape.

                – mosvy
                6 hours ago












              • @mosvy, fd 0, 1 and 2 on the remote command will be 3 different pipes. The data travels through 3 different channels multiplexed in the ssh connection, but those are uni-directional (from client to sever for fd 0 and from server to client for 1 and 2), so even on systems where pipes are bidirectional, that won't work. On Linux, openening /dev/stderr in readonly mode gives on the other end of the pipe, so it would never work either.

                – Stéphane Chazelas
                6 hours ago











              • Note that the last one assumes the login shell of the user on remote.name is Bourne-like (3<&2 is a Bourne shell operator, and sshd runs the login shell of the user to interpret the command sent by the client)

                – Stéphane Chazelas
                6 hours ago







              • 1





                @StéphaneChazelas Nope, a single ssh channel is used for stdin/stdout/stderr, and the stderr data is transferred via SSH_MSG_CHANNEL_EXTENDED_DATA messages with the type set to SSH_EXTENDED_DATA_STDERR. You can read the whole thing here

                – mosvy
                5 hours ago














              0












              0








              0







              Unfortunately there's not a great way to do this directly, since the ssh client will only pass the three file descriptors (stdin, stdout and stderr) to the server and it doesn't have provisions to pass additional file descriptors (which would be helpful for this particular use case.)



              (Also note that the SSH protocol has provisions to pass additional file descriptors, only the ssh client doesn't implement a way to use that feature. Theoretically, extending the client with a patch would be enough to expose this feature.)



              One hacky way to accomplish what you're looking for is to use file descriptor 2 (the stderr file descriptor) to pass the second file. Something like:



              $ ssh remote.name 
              /path/to/program -a /dev/stdin -b /dev/stderr
              <file1.txt 2<file2.txt


              This should work, it just might cause an issue if program tries to write to stderr. You can work around that by re-juggling the file descriptors on the remote end before you run program. You can move file2.txt to file descriptor 3 and re-open stderr to mirror stdout:



              $ ssh remote.name 
              /path/to/program -a /dev/stdin -b /dev/fd/3
              '3<&2' '2>&1'
              <file1.txt 2<file2.txt





              share|improve this answer













              Unfortunately there's not a great way to do this directly, since the ssh client will only pass the three file descriptors (stdin, stdout and stderr) to the server and it doesn't have provisions to pass additional file descriptors (which would be helpful for this particular use case.)



              (Also note that the SSH protocol has provisions to pass additional file descriptors, only the ssh client doesn't implement a way to use that feature. Theoretically, extending the client with a patch would be enough to expose this feature.)



              One hacky way to accomplish what you're looking for is to use file descriptor 2 (the stderr file descriptor) to pass the second file. Something like:



              $ ssh remote.name 
              /path/to/program -a /dev/stdin -b /dev/stderr
              <file1.txt 2<file2.txt


              This should work, it just might cause an issue if program tries to write to stderr. You can work around that by re-juggling the file descriptors on the remote end before you run program. You can move file2.txt to file descriptor 3 and re-open stderr to mirror stdout:



              $ ssh remote.name 
              /path/to/program -a /dev/stdin -b /dev/fd/3
              '3<&2' '2>&1'
              <file1.txt 2<file2.txt






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 7 hours ago









              filbrandenfilbranden

              11.6k21849




              11.6k21849












              • I haven't really tested this (typing on a phone) but at least in theory I'd expect it to work. Let me know if for some reason it doesn't. Cheers!

                – filbranden
                6 hours ago











              • That won't work at all. Not even with a hacked ssh. AFAIK stderr doesn't use a separate channel, but some special kind of message. But yes, being able to access ssh channels as pipes or unnamed unix domain sockets (instead of having to do socket forwardings) would be great, it just doesn't seem to be possible in any kind or shape.

                – mosvy
                6 hours ago












              • @mosvy, fd 0, 1 and 2 on the remote command will be 3 different pipes. The data travels through 3 different channels multiplexed in the ssh connection, but those are uni-directional (from client to sever for fd 0 and from server to client for 1 and 2), so even on systems where pipes are bidirectional, that won't work. On Linux, openening /dev/stderr in readonly mode gives on the other end of the pipe, so it would never work either.

                – Stéphane Chazelas
                6 hours ago











              • Note that the last one assumes the login shell of the user on remote.name is Bourne-like (3<&2 is a Bourne shell operator, and sshd runs the login shell of the user to interpret the command sent by the client)

                – Stéphane Chazelas
                6 hours ago







              • 1





                @StéphaneChazelas Nope, a single ssh channel is used for stdin/stdout/stderr, and the stderr data is transferred via SSH_MSG_CHANNEL_EXTENDED_DATA messages with the type set to SSH_EXTENDED_DATA_STDERR. You can read the whole thing here

                – mosvy
                5 hours ago


















              • I haven't really tested this (typing on a phone) but at least in theory I'd expect it to work. Let me know if for some reason it doesn't. Cheers!

                – filbranden
                6 hours ago











              • That won't work at all. Not even with a hacked ssh. AFAIK stderr doesn't use a separate channel, but some special kind of message. But yes, being able to access ssh channels as pipes or unnamed unix domain sockets (instead of having to do socket forwardings) would be great, it just doesn't seem to be possible in any kind or shape.

                – mosvy
                6 hours ago












              • @mosvy, fd 0, 1 and 2 on the remote command will be 3 different pipes. The data travels through 3 different channels multiplexed in the ssh connection, but those are uni-directional (from client to sever for fd 0 and from server to client for 1 and 2), so even on systems where pipes are bidirectional, that won't work. On Linux, openening /dev/stderr in readonly mode gives on the other end of the pipe, so it would never work either.

                – Stéphane Chazelas
                6 hours ago











              • Note that the last one assumes the login shell of the user on remote.name is Bourne-like (3<&2 is a Bourne shell operator, and sshd runs the login shell of the user to interpret the command sent by the client)

                – Stéphane Chazelas
                6 hours ago







              • 1





                @StéphaneChazelas Nope, a single ssh channel is used for stdin/stdout/stderr, and the stderr data is transferred via SSH_MSG_CHANNEL_EXTENDED_DATA messages with the type set to SSH_EXTENDED_DATA_STDERR. You can read the whole thing here

                – mosvy
                5 hours ago

















              I haven't really tested this (typing on a phone) but at least in theory I'd expect it to work. Let me know if for some reason it doesn't. Cheers!

              – filbranden
              6 hours ago





              I haven't really tested this (typing on a phone) but at least in theory I'd expect it to work. Let me know if for some reason it doesn't. Cheers!

              – filbranden
              6 hours ago













              That won't work at all. Not even with a hacked ssh. AFAIK stderr doesn't use a separate channel, but some special kind of message. But yes, being able to access ssh channels as pipes or unnamed unix domain sockets (instead of having to do socket forwardings) would be great, it just doesn't seem to be possible in any kind or shape.

              – mosvy
              6 hours ago






              That won't work at all. Not even with a hacked ssh. AFAIK stderr doesn't use a separate channel, but some special kind of message. But yes, being able to access ssh channels as pipes or unnamed unix domain sockets (instead of having to do socket forwardings) would be great, it just doesn't seem to be possible in any kind or shape.

              – mosvy
              6 hours ago














              @mosvy, fd 0, 1 and 2 on the remote command will be 3 different pipes. The data travels through 3 different channels multiplexed in the ssh connection, but those are uni-directional (from client to sever for fd 0 and from server to client for 1 and 2), so even on systems where pipes are bidirectional, that won't work. On Linux, openening /dev/stderr in readonly mode gives on the other end of the pipe, so it would never work either.

              – Stéphane Chazelas
              6 hours ago





              @mosvy, fd 0, 1 and 2 on the remote command will be 3 different pipes. The data travels through 3 different channels multiplexed in the ssh connection, but those are uni-directional (from client to sever for fd 0 and from server to client for 1 and 2), so even on systems where pipes are bidirectional, that won't work. On Linux, openening /dev/stderr in readonly mode gives on the other end of the pipe, so it would never work either.

              – Stéphane Chazelas
              6 hours ago













              Note that the last one assumes the login shell of the user on remote.name is Bourne-like (3<&2 is a Bourne shell operator, and sshd runs the login shell of the user to interpret the command sent by the client)

              – Stéphane Chazelas
              6 hours ago






              Note that the last one assumes the login shell of the user on remote.name is Bourne-like (3<&2 is a Bourne shell operator, and sshd runs the login shell of the user to interpret the command sent by the client)

              – Stéphane Chazelas
              6 hours ago





              1




              1





              @StéphaneChazelas Nope, a single ssh channel is used for stdin/stdout/stderr, and the stderr data is transferred via SSH_MSG_CHANNEL_EXTENDED_DATA messages with the type set to SSH_EXTENDED_DATA_STDERR. You can read the whole thing here

              – mosvy
              5 hours ago






              @StéphaneChazelas Nope, a single ssh channel is used for stdin/stdout/stderr, and the stderr data is transferred via SSH_MSG_CHANNEL_EXTENDED_DATA messages with the type set to SSH_EXTENDED_DATA_STDERR. You can read the whole thing here

              – mosvy
              5 hours ago












              0














              If you're allowed to forward ports over ssh, and you have access to wget on the remote machine and to busybox on the local machine, you can do something like:



              mkdir /tmp/test; cd /tmp/test
              echo 1st_file > 1st_file
              echo 2nd_file > 2nd_file

              busybox httpd -f -p 127.0.0.1:11080 &
              ssh USER@HOST -R 10080:127.0.0.1:11080 '
              cat <(wget -q -O- http://localhost:10080/1st_file)
              <(wget -q -O- http://localhost:10080/2nd_file)
              '
              kill $!


              (using cat as an example program which takes two file arguments).



              Only the ability to forward ports via -R is essential -- instead of doing http, you can use other methods (2 netcats and 2 forwardings, /dev/tcp/ in bash on the remote side, etc). But convincing a netcat without the -N option to close the connection proved to be much messier than I though.



              There may be ways to replace the <(...) process subtitutions if the shell on the remote machine isn't ksh- or bash- like.



              All in all, this isn't too great -- better knowledge about the exact system/shells/config/permissions (which you haven't provided) could allow for smarter solutions.






              share|improve this answer





























                0














                If you're allowed to forward ports over ssh, and you have access to wget on the remote machine and to busybox on the local machine, you can do something like:



                mkdir /tmp/test; cd /tmp/test
                echo 1st_file > 1st_file
                echo 2nd_file > 2nd_file

                busybox httpd -f -p 127.0.0.1:11080 &
                ssh USER@HOST -R 10080:127.0.0.1:11080 '
                cat <(wget -q -O- http://localhost:10080/1st_file)
                <(wget -q -O- http://localhost:10080/2nd_file)
                '
                kill $!


                (using cat as an example program which takes two file arguments).



                Only the ability to forward ports via -R is essential -- instead of doing http, you can use other methods (2 netcats and 2 forwardings, /dev/tcp/ in bash on the remote side, etc). But convincing a netcat without the -N option to close the connection proved to be much messier than I though.



                There may be ways to replace the <(...) process subtitutions if the shell on the remote machine isn't ksh- or bash- like.



                All in all, this isn't too great -- better knowledge about the exact system/shells/config/permissions (which you haven't provided) could allow for smarter solutions.






                share|improve this answer



























                  0












                  0








                  0







                  If you're allowed to forward ports over ssh, and you have access to wget on the remote machine and to busybox on the local machine, you can do something like:



                  mkdir /tmp/test; cd /tmp/test
                  echo 1st_file > 1st_file
                  echo 2nd_file > 2nd_file

                  busybox httpd -f -p 127.0.0.1:11080 &
                  ssh USER@HOST -R 10080:127.0.0.1:11080 '
                  cat <(wget -q -O- http://localhost:10080/1st_file)
                  <(wget -q -O- http://localhost:10080/2nd_file)
                  '
                  kill $!


                  (using cat as an example program which takes two file arguments).



                  Only the ability to forward ports via -R is essential -- instead of doing http, you can use other methods (2 netcats and 2 forwardings, /dev/tcp/ in bash on the remote side, etc). But convincing a netcat without the -N option to close the connection proved to be much messier than I though.



                  There may be ways to replace the <(...) process subtitutions if the shell on the remote machine isn't ksh- or bash- like.



                  All in all, this isn't too great -- better knowledge about the exact system/shells/config/permissions (which you haven't provided) could allow for smarter solutions.






                  share|improve this answer















                  If you're allowed to forward ports over ssh, and you have access to wget on the remote machine and to busybox on the local machine, you can do something like:



                  mkdir /tmp/test; cd /tmp/test
                  echo 1st_file > 1st_file
                  echo 2nd_file > 2nd_file

                  busybox httpd -f -p 127.0.0.1:11080 &
                  ssh USER@HOST -R 10080:127.0.0.1:11080 '
                  cat <(wget -q -O- http://localhost:10080/1st_file)
                  <(wget -q -O- http://localhost:10080/2nd_file)
                  '
                  kill $!


                  (using cat as an example program which takes two file arguments).



                  Only the ability to forward ports via -R is essential -- instead of doing http, you can use other methods (2 netcats and 2 forwardings, /dev/tcp/ in bash on the remote side, etc). But convincing a netcat without the -N option to close the connection proved to be much messier than I though.



                  There may be ways to replace the <(...) process subtitutions if the shell on the remote machine isn't ksh- or bash- like.



                  All in all, this isn't too great -- better knowledge about the exact system/shells/config/permissions (which you haven't provided) could allow for smarter solutions.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 3 hours ago

























                  answered 4 hours ago









                  mosvymosvy

                  12.4k11542




                  12.4k11542





















                      0














                      Perhaps not exactly what you want... But maybe consider sending a tarball through the pipe opened by ssh?



                      You said that:




                      I'm not allowed to store files on the host.




                      It's possible that you don't have a writable home directory or other convenient location to store files long term, but I'd say it's unlikely you don't have any writable location, even if a temporary tmpfs that will be made available only for your particular connection.



                      Many programs (and even libc routines) require a writable /tmp, so it's very likely one will be available to you.



                      Then you could use a script that will unpack the tarball into a temporary directory, run your program and cleanup through the ssh connection.



                      Something like:



                      $ tar cf - file1.txt file2.txt |
                      ssh host.name '
                      set -e
                      tmpdir=$(mktemp -d -t tmp.XXXXXXXXXX)
                      cleanup () rm -rf "$tmpdir";
                      trap cleanup EXIT
                      cd "$tmpdir"
                      tar xf -
                      /path/to/program -a file1.txt -b file2.txt
                      '


                      This might need some extra care with file paths and there are some corner cases to consider (test for them), but the general approach should work.



                      If no writable directory is available, a possible approach would be to modify program to take a tarball as single input and unpack its contents to memory. For instance, if program is a Python script, then using the built-in tarfile module would easily accomplish something like that.






                      share|improve this answer


















                      • 1





                        Even without going through the trouble of tarballing it - I've decided more or less to just write a file to /tmp/ and use it directly.

                        – Green Cloak Guy
                        2 hours ago











                      • The tarball approach has some advantages, as you use a single ssh connection (no need to test for success/failure) and multiple concurrent runs are not likely to run into each other (use and/or delete files in /tmp meant for separate runs.) But I think that's the best you'll get from ssh as it exists now. Good luck!

                        – filbranden
                        2 hours ago






                      • 1





                        @GreenCloakGuy So after all, you can store files on the server just fine. Please modify the question accordingly.

                        – mosvy
                        2 hours ago















                      0














                      Perhaps not exactly what you want... But maybe consider sending a tarball through the pipe opened by ssh?



                      You said that:




                      I'm not allowed to store files on the host.




                      It's possible that you don't have a writable home directory or other convenient location to store files long term, but I'd say it's unlikely you don't have any writable location, even if a temporary tmpfs that will be made available only for your particular connection.



                      Many programs (and even libc routines) require a writable /tmp, so it's very likely one will be available to you.



                      Then you could use a script that will unpack the tarball into a temporary directory, run your program and cleanup through the ssh connection.



                      Something like:



                      $ tar cf - file1.txt file2.txt |
                      ssh host.name '
                      set -e
                      tmpdir=$(mktemp -d -t tmp.XXXXXXXXXX)
                      cleanup () rm -rf "$tmpdir";
                      trap cleanup EXIT
                      cd "$tmpdir"
                      tar xf -
                      /path/to/program -a file1.txt -b file2.txt
                      '


                      This might need some extra care with file paths and there are some corner cases to consider (test for them), but the general approach should work.



                      If no writable directory is available, a possible approach would be to modify program to take a tarball as single input and unpack its contents to memory. For instance, if program is a Python script, then using the built-in tarfile module would easily accomplish something like that.






                      share|improve this answer


















                      • 1





                        Even without going through the trouble of tarballing it - I've decided more or less to just write a file to /tmp/ and use it directly.

                        – Green Cloak Guy
                        2 hours ago











                      • The tarball approach has some advantages, as you use a single ssh connection (no need to test for success/failure) and multiple concurrent runs are not likely to run into each other (use and/or delete files in /tmp meant for separate runs.) But I think that's the best you'll get from ssh as it exists now. Good luck!

                        – filbranden
                        2 hours ago






                      • 1





                        @GreenCloakGuy So after all, you can store files on the server just fine. Please modify the question accordingly.

                        – mosvy
                        2 hours ago













                      0












                      0








                      0







                      Perhaps not exactly what you want... But maybe consider sending a tarball through the pipe opened by ssh?



                      You said that:




                      I'm not allowed to store files on the host.




                      It's possible that you don't have a writable home directory or other convenient location to store files long term, but I'd say it's unlikely you don't have any writable location, even if a temporary tmpfs that will be made available only for your particular connection.



                      Many programs (and even libc routines) require a writable /tmp, so it's very likely one will be available to you.



                      Then you could use a script that will unpack the tarball into a temporary directory, run your program and cleanup through the ssh connection.



                      Something like:



                      $ tar cf - file1.txt file2.txt |
                      ssh host.name '
                      set -e
                      tmpdir=$(mktemp -d -t tmp.XXXXXXXXXX)
                      cleanup () rm -rf "$tmpdir";
                      trap cleanup EXIT
                      cd "$tmpdir"
                      tar xf -
                      /path/to/program -a file1.txt -b file2.txt
                      '


                      This might need some extra care with file paths and there are some corner cases to consider (test for them), but the general approach should work.



                      If no writable directory is available, a possible approach would be to modify program to take a tarball as single input and unpack its contents to memory. For instance, if program is a Python script, then using the built-in tarfile module would easily accomplish something like that.






                      share|improve this answer













                      Perhaps not exactly what you want... But maybe consider sending a tarball through the pipe opened by ssh?



                      You said that:




                      I'm not allowed to store files on the host.




                      It's possible that you don't have a writable home directory or other convenient location to store files long term, but I'd say it's unlikely you don't have any writable location, even if a temporary tmpfs that will be made available only for your particular connection.



                      Many programs (and even libc routines) require a writable /tmp, so it's very likely one will be available to you.



                      Then you could use a script that will unpack the tarball into a temporary directory, run your program and cleanup through the ssh connection.



                      Something like:



                      $ tar cf - file1.txt file2.txt |
                      ssh host.name '
                      set -e
                      tmpdir=$(mktemp -d -t tmp.XXXXXXXXXX)
                      cleanup () rm -rf "$tmpdir";
                      trap cleanup EXIT
                      cd "$tmpdir"
                      tar xf -
                      /path/to/program -a file1.txt -b file2.txt
                      '


                      This might need some extra care with file paths and there are some corner cases to consider (test for them), but the general approach should work.



                      If no writable directory is available, a possible approach would be to modify program to take a tarball as single input and unpack its contents to memory. For instance, if program is a Python script, then using the built-in tarfile module would easily accomplish something like that.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 2 hours ago









                      filbrandenfilbranden

                      11.6k21849




                      11.6k21849







                      • 1





                        Even without going through the trouble of tarballing it - I've decided more or less to just write a file to /tmp/ and use it directly.

                        – Green Cloak Guy
                        2 hours ago











                      • The tarball approach has some advantages, as you use a single ssh connection (no need to test for success/failure) and multiple concurrent runs are not likely to run into each other (use and/or delete files in /tmp meant for separate runs.) But I think that's the best you'll get from ssh as it exists now. Good luck!

                        – filbranden
                        2 hours ago






                      • 1





                        @GreenCloakGuy So after all, you can store files on the server just fine. Please modify the question accordingly.

                        – mosvy
                        2 hours ago












                      • 1





                        Even without going through the trouble of tarballing it - I've decided more or less to just write a file to /tmp/ and use it directly.

                        – Green Cloak Guy
                        2 hours ago











                      • The tarball approach has some advantages, as you use a single ssh connection (no need to test for success/failure) and multiple concurrent runs are not likely to run into each other (use and/or delete files in /tmp meant for separate runs.) But I think that's the best you'll get from ssh as it exists now. Good luck!

                        – filbranden
                        2 hours ago






                      • 1





                        @GreenCloakGuy So after all, you can store files on the server just fine. Please modify the question accordingly.

                        – mosvy
                        2 hours ago







                      1




                      1





                      Even without going through the trouble of tarballing it - I've decided more or less to just write a file to /tmp/ and use it directly.

                      – Green Cloak Guy
                      2 hours ago





                      Even without going through the trouble of tarballing it - I've decided more or less to just write a file to /tmp/ and use it directly.

                      – Green Cloak Guy
                      2 hours ago













                      The tarball approach has some advantages, as you use a single ssh connection (no need to test for success/failure) and multiple concurrent runs are not likely to run into each other (use and/or delete files in /tmp meant for separate runs.) But I think that's the best you'll get from ssh as it exists now. Good luck!

                      – filbranden
                      2 hours ago





                      The tarball approach has some advantages, as you use a single ssh connection (no need to test for success/failure) and multiple concurrent runs are not likely to run into each other (use and/or delete files in /tmp meant for separate runs.) But I think that's the best you'll get from ssh as it exists now. Good luck!

                      – filbranden
                      2 hours ago




                      1




                      1





                      @GreenCloakGuy So after all, you can store files on the server just fine. Please modify the question accordingly.

                      – mosvy
                      2 hours ago





                      @GreenCloakGuy So after all, you can store files on the server just fine. Please modify the question accordingly.

                      – mosvy
                      2 hours ago










                      Green Cloak Guy is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded


















                      Green Cloak Guy is a new contributor. Be nice, and check out our Code of Conduct.












                      Green Cloak Guy is a new contributor. Be nice, and check out our Code of Conduct.











                      Green Cloak Guy 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%2f522637%2fpassing-multiple-files-through-stdin-over-ssh%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

                      Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                      Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                      Tom Holland Mục lục Đầu đời và giáo dục | Sự nghiệp | Cuộc sống cá nhân | Phim tham gia | Giải thưởng và đề cử | Chú thích | Liên kết ngoài | Trình đơn chuyển hướngProfile“Person Details for Thomas Stanley Holland, "England and Wales Birth Registration Index, 1837-2008" — FamilySearch.org”"Meet Tom Holland... the 16-year-old star of The Impossible""Schoolboy actor Tom Holland finds himself in Oscar contention for role in tsunami drama"“Naomi Watts on the Prince William and Harry's reaction to her film about the late Princess Diana”lưu trữ"Holland and Pflueger Are West End's Two New 'Billy Elliots'""I'm so envious of my son, the movie star! British writer Dominic Holland's spent 20 years trying to crack Hollywood - but he's been beaten to it by a very unlikely rival"“Richard and Margaret Povey of Jersey, Channel Islands, UK: Information about Thomas Stanley Holland”"Tom Holland to play Billy Elliot""New Billy Elliot leaving the garage"Billy Elliot the Musical - Tom Holland - Billy"A Tale of four Billys: Tom Holland""The Feel Good Factor""Thames Christian College schoolboys join Myleene Klass for The Feelgood Factor""Government launches £600,000 arts bursaries pilot""BILLY's Chapman, Holland, Gardner & Jackson-Keen Visit Prime Minister""Elton John 'blown away' by Billy Elliot fifth birthday" (video with John's interview and fragments of Holland's performance)"First News interviews Arrietty's Tom Holland"“33rd Critics' Circle Film Awards winners”“National Board of Review Current Awards”Bản gốc"Ron Howard Whaling Tale 'In The Heart Of The Sea' Casts Tom Holland"“'Spider-Man' Finds Tom Holland to Star as New Web-Slinger”lưu trữ“Captain America: Civil War (2016)”“Film Review: ‘Captain America: Civil War’”lưu trữ“‘Captain America: Civil War’ review: Choose your own avenger”lưu trữ“The Lost City of Z reviews”“Sony Pictures and Marvel Studios Find Their 'Spider-Man' Star and Director”“‘Mary Magdalene’, ‘Current War’ & ‘Wind River’ Get 2017 Release Dates From Weinstein”“Lionsgate Unleashing Daisy Ridley & Tom Holland Starrer ‘Chaos Walking’ In Cannes”“PTA's 'Master' Leads Chicago Film Critics Nominations, UPDATED: Houston and Indiana Critics Nominations”“Nominaciones Goya 2013 Telecinco Cinema – ENG”“Jameson Empire Film Awards: Martin Freeman wins best actor for performance in The Hobbit”“34th Annual Young Artist Awards”Bản gốc“Teen Choice Awards 2016—Captain America: Civil War Leads Second Wave of Nominations”“BAFTA Film Award Nominations: ‘La La Land’ Leads Race”“Saturn Awards Nominations 2017: 'Rogue One,' 'Walking Dead' Lead”Tom HollandTom HollandTom HollandTom Hollandmedia.gettyimages.comWorldCat Identities300279794no20130442900000 0004 0355 42791085670554170004732cb16706349t(data)XX5557367