Copy input to clipboard over SSH?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












27















Here's my usage case:



  • I'm often connected to other computers over SSH for work and I often need to copy and paste documents/text from the server to locally running editors for writing examples and sharing text.

  • Often, if the text is small enough, I'll simply copy the output from my terminal program (gnome-terminal at the moment) and paste it.

  • However, when it comes to entire documents, my options are quite limited. I can either copy the document chunk-by-chunk, or scp it to the local machine.

Is there a way to use a program such as xclip which will allow me to copy remote stdin to the local X server's clipboard? Something to the effect of:



cat myconffile.conf | sed ... | copy-over-ssh-to-local-clipboard


would be awesome. Does something exist to make this possible?










share|improve this question


























    27















    Here's my usage case:



    • I'm often connected to other computers over SSH for work and I often need to copy and paste documents/text from the server to locally running editors for writing examples and sharing text.

    • Often, if the text is small enough, I'll simply copy the output from my terminal program (gnome-terminal at the moment) and paste it.

    • However, when it comes to entire documents, my options are quite limited. I can either copy the document chunk-by-chunk, or scp it to the local machine.

    Is there a way to use a program such as xclip which will allow me to copy remote stdin to the local X server's clipboard? Something to the effect of:



    cat myconffile.conf | sed ... | copy-over-ssh-to-local-clipboard


    would be awesome. Does something exist to make this possible?










    share|improve this question
























      27












      27








      27


      7






      Here's my usage case:



      • I'm often connected to other computers over SSH for work and I often need to copy and paste documents/text from the server to locally running editors for writing examples and sharing text.

      • Often, if the text is small enough, I'll simply copy the output from my terminal program (gnome-terminal at the moment) and paste it.

      • However, when it comes to entire documents, my options are quite limited. I can either copy the document chunk-by-chunk, or scp it to the local machine.

      Is there a way to use a program such as xclip which will allow me to copy remote stdin to the local X server's clipboard? Something to the effect of:



      cat myconffile.conf | sed ... | copy-over-ssh-to-local-clipboard


      would be awesome. Does something exist to make this possible?










      share|improve this question














      Here's my usage case:



      • I'm often connected to other computers over SSH for work and I often need to copy and paste documents/text from the server to locally running editors for writing examples and sharing text.

      • Often, if the text is small enough, I'll simply copy the output from my terminal program (gnome-terminal at the moment) and paste it.

      • However, when it comes to entire documents, my options are quite limited. I can either copy the document chunk-by-chunk, or scp it to the local machine.

      Is there a way to use a program such as xclip which will allow me to copy remote stdin to the local X server's clipboard? Something to the effect of:



      cat myconffile.conf | sed ... | copy-over-ssh-to-local-clipboard


      would be awesome. Does something exist to make this possible?







      ssh xorg clipboard






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 14 '11 at 23:41









      Naftuli KayNaftuli Kay

      12.3k56158252




      12.3k56158252




















          8 Answers
          8






          active

          oldest

          votes


















          15














          If you run ssh with X forwarding, this is transparent: remote commands (including xclip) have access to your X server (including its keyboard). Make sure you have ForwardX11 yes in your ~/.ssh/config and X11Forwarding yes in the server sshd_config (depending on your distributions, these options may be on or off by default).



          <myconffile.conf sed ... | xclip -i


          There are other ways of working on remote files that may be more convenient, for example mounting remote directories on your local machine with SSHfs, or opening remote files in Emacs with Tramp. If you have ssh and FUSE set up and SSHfs installed, SSHfs is as easy as mkdir ~/net/myserver; sshfs myserver:/ ~/net/myserver. If you have ssh set up and Emacs installed, Tramp is as easy as opening /myserver:/path/to/file.






          share|improve this answer


















          • 1





            Any security vulnerabilities to running things this way by default in the conf file?

            – Naftuli Kay
            Jul 15 '11 at 1:15












          • No. All the x11 traffic is forwarded through the SSH channel.

            – Shadur
            Jul 15 '11 at 4:09






          • 2





            @TKKocheran Not really. On the server side, none. On the client side, a little, in that it gives the server administrator a way into your client, but in 99% of cases the server admin has a way anyway; see If someone is signed into SSH on my computer, can I access their computer?

            – Gilles
            Jul 15 '11 at 9:33


















          5














          You don't need anything special; since xclip works over stdin, just



          ssh remotehost xclip < myconf.conf


          Why would it need to be modified with sed? ssh is transparent to data when not used as a terminal, and is commonly used in pipelines such as



          tar cfz - somedir | ssh remotehost 'cd destdir; tar xfz -'`





          share|improve this answer























          • Is there a way to do it from within an existing SSH session? I'd really prefer not to have to open up another terminal window if I already have one open to the machine in question.

            – Naftuli Kay
            Jul 14 '11 at 23:56











          • And sed` is just there as an example, if I'd like to perform any processing on the stdin before copying it to the clipboard, I'd like that option.

            – Naftuli Kay
            Jul 14 '11 at 23:57











          • No, there's no way to inject data into an existing ssh session (it wouldn't be very secure if you could). You can set up the ssh ControlMaster stuff to multiplex additional connections over an existing one, but it's not really something for beginners and you still do it the same way afterward, by switching to another local terminal and running the command above (which does not open a new terminal window).

            – geekosaur
            Jul 15 '11 at 0:03


















          4














          Here's how you would do it on OSX from your local machine



          ssh remotehost.com "<some/file.txt" | pbcopy





          share|improve this answer






























            2














            if your local machine is running windows(7+) you can just use this from the CommandLine:



            ssh user@server cat /home/user/file | clip





            share|improve this answer






























              1














              ~/.ssh/config:



              Host REMOTEHOST
              ...
              ForwardX11 yes


              /etc/ssh/sshd_config:



              X11Forwarding yes


              bash:



              $ xclip -o | ssh REMOTEHOST 'DISPLAY=:0 xclip -i'





              share|improve this answer






























                0














                I have similar issue with LUbuntu's lxterminal (tested various terminals) pasting clipboard to an ssh session. If clipboard has more than about 100 bytes the session timeouts and fails.



                If I connect via ssh to almost any CentOS 5.x server and then connect to the target server, clipboard paste works without any issue for any reasonable data size.






                share|improve this answer
































                  0














                  Very similar to @d-raev's and @william-casarin solutions, however, it is different so I'm sharing what worked for me.



                  The command:



                  ssh user@host cat <myconffile.conf | xclip -sel clip



                  Explanation:



                  This is using ssh to create a secure tunnel, login to user @ host or ip, then execute cat to print the contents of <myconffile.conf to stdout then piping that to the command xclip -sel clip on your local machine, which places the contents of <myconffile.conf into the clipboard on your local machine.



                  Real-world example usage:



                  I use this command structure for tasks such as pasting ssh keys into github (allowing a simple ctrl-V or paste selection after I run the command) on with Bash on Ubuntu 16.04 and 18.04. Check out man ssh, man cat, and man xclip for behavior and option details.






                  share|improve this answer






























                    -1














                    https://secure.wikimedia.org/wikipedia/en/wiki/Base64



                    You can convert your clipboard data with Base64 to ASCII text. Then you can push that through inside an already existing SSH connection.






                    share|improve this answer

























                    • Why convert to anything? It's already text in this case and even if it was binary there would be no reason you couldn't send it across a pipeline like this.

                      – Caleb
                      Aug 2 '11 at 10:41











                    • clipboard could contain binary data, e.g.: a compiled application

                      – LanceBaynes
                      Aug 2 '11 at 14:34











                    • Yes it could, but why would that be a problem? Binary data can be transferred through a pipe and ssh tunnel.

                      – Caleb
                      Aug 2 '11 at 14:39










                    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
                    );



                    );













                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f16694%2fcopy-input-to-clipboard-over-ssh%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown

























                    8 Answers
                    8






                    active

                    oldest

                    votes








                    8 Answers
                    8






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes









                    15














                    If you run ssh with X forwarding, this is transparent: remote commands (including xclip) have access to your X server (including its keyboard). Make sure you have ForwardX11 yes in your ~/.ssh/config and X11Forwarding yes in the server sshd_config (depending on your distributions, these options may be on or off by default).



                    <myconffile.conf sed ... | xclip -i


                    There are other ways of working on remote files that may be more convenient, for example mounting remote directories on your local machine with SSHfs, or opening remote files in Emacs with Tramp. If you have ssh and FUSE set up and SSHfs installed, SSHfs is as easy as mkdir ~/net/myserver; sshfs myserver:/ ~/net/myserver. If you have ssh set up and Emacs installed, Tramp is as easy as opening /myserver:/path/to/file.






                    share|improve this answer


















                    • 1





                      Any security vulnerabilities to running things this way by default in the conf file?

                      – Naftuli Kay
                      Jul 15 '11 at 1:15












                    • No. All the x11 traffic is forwarded through the SSH channel.

                      – Shadur
                      Jul 15 '11 at 4:09






                    • 2





                      @TKKocheran Not really. On the server side, none. On the client side, a little, in that it gives the server administrator a way into your client, but in 99% of cases the server admin has a way anyway; see If someone is signed into SSH on my computer, can I access their computer?

                      – Gilles
                      Jul 15 '11 at 9:33















                    15














                    If you run ssh with X forwarding, this is transparent: remote commands (including xclip) have access to your X server (including its keyboard). Make sure you have ForwardX11 yes in your ~/.ssh/config and X11Forwarding yes in the server sshd_config (depending on your distributions, these options may be on or off by default).



                    <myconffile.conf sed ... | xclip -i


                    There are other ways of working on remote files that may be more convenient, for example mounting remote directories on your local machine with SSHfs, or opening remote files in Emacs with Tramp. If you have ssh and FUSE set up and SSHfs installed, SSHfs is as easy as mkdir ~/net/myserver; sshfs myserver:/ ~/net/myserver. If you have ssh set up and Emacs installed, Tramp is as easy as opening /myserver:/path/to/file.






                    share|improve this answer


















                    • 1





                      Any security vulnerabilities to running things this way by default in the conf file?

                      – Naftuli Kay
                      Jul 15 '11 at 1:15












                    • No. All the x11 traffic is forwarded through the SSH channel.

                      – Shadur
                      Jul 15 '11 at 4:09






                    • 2





                      @TKKocheran Not really. On the server side, none. On the client side, a little, in that it gives the server administrator a way into your client, but in 99% of cases the server admin has a way anyway; see If someone is signed into SSH on my computer, can I access their computer?

                      – Gilles
                      Jul 15 '11 at 9:33













                    15












                    15








                    15







                    If you run ssh with X forwarding, this is transparent: remote commands (including xclip) have access to your X server (including its keyboard). Make sure you have ForwardX11 yes in your ~/.ssh/config and X11Forwarding yes in the server sshd_config (depending on your distributions, these options may be on or off by default).



                    <myconffile.conf sed ... | xclip -i


                    There are other ways of working on remote files that may be more convenient, for example mounting remote directories on your local machine with SSHfs, or opening remote files in Emacs with Tramp. If you have ssh and FUSE set up and SSHfs installed, SSHfs is as easy as mkdir ~/net/myserver; sshfs myserver:/ ~/net/myserver. If you have ssh set up and Emacs installed, Tramp is as easy as opening /myserver:/path/to/file.






                    share|improve this answer













                    If you run ssh with X forwarding, this is transparent: remote commands (including xclip) have access to your X server (including its keyboard). Make sure you have ForwardX11 yes in your ~/.ssh/config and X11Forwarding yes in the server sshd_config (depending on your distributions, these options may be on or off by default).



                    <myconffile.conf sed ... | xclip -i


                    There are other ways of working on remote files that may be more convenient, for example mounting remote directories on your local machine with SSHfs, or opening remote files in Emacs with Tramp. If you have ssh and FUSE set up and SSHfs installed, SSHfs is as easy as mkdir ~/net/myserver; sshfs myserver:/ ~/net/myserver. If you have ssh set up and Emacs installed, Tramp is as easy as opening /myserver:/path/to/file.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 15 '11 at 0:06









                    GillesGilles

                    533k12810721594




                    533k12810721594







                    • 1





                      Any security vulnerabilities to running things this way by default in the conf file?

                      – Naftuli Kay
                      Jul 15 '11 at 1:15












                    • No. All the x11 traffic is forwarded through the SSH channel.

                      – Shadur
                      Jul 15 '11 at 4:09






                    • 2





                      @TKKocheran Not really. On the server side, none. On the client side, a little, in that it gives the server administrator a way into your client, but in 99% of cases the server admin has a way anyway; see If someone is signed into SSH on my computer, can I access their computer?

                      – Gilles
                      Jul 15 '11 at 9:33












                    • 1





                      Any security vulnerabilities to running things this way by default in the conf file?

                      – Naftuli Kay
                      Jul 15 '11 at 1:15












                    • No. All the x11 traffic is forwarded through the SSH channel.

                      – Shadur
                      Jul 15 '11 at 4:09






                    • 2





                      @TKKocheran Not really. On the server side, none. On the client side, a little, in that it gives the server administrator a way into your client, but in 99% of cases the server admin has a way anyway; see If someone is signed into SSH on my computer, can I access their computer?

                      – Gilles
                      Jul 15 '11 at 9:33







                    1




                    1





                    Any security vulnerabilities to running things this way by default in the conf file?

                    – Naftuli Kay
                    Jul 15 '11 at 1:15






                    Any security vulnerabilities to running things this way by default in the conf file?

                    – Naftuli Kay
                    Jul 15 '11 at 1:15














                    No. All the x11 traffic is forwarded through the SSH channel.

                    – Shadur
                    Jul 15 '11 at 4:09





                    No. All the x11 traffic is forwarded through the SSH channel.

                    – Shadur
                    Jul 15 '11 at 4:09




                    2




                    2





                    @TKKocheran Not really. On the server side, none. On the client side, a little, in that it gives the server administrator a way into your client, but in 99% of cases the server admin has a way anyway; see If someone is signed into SSH on my computer, can I access their computer?

                    – Gilles
                    Jul 15 '11 at 9:33





                    @TKKocheran Not really. On the server side, none. On the client side, a little, in that it gives the server administrator a way into your client, but in 99% of cases the server admin has a way anyway; see If someone is signed into SSH on my computer, can I access their computer?

                    – Gilles
                    Jul 15 '11 at 9:33













                    5














                    You don't need anything special; since xclip works over stdin, just



                    ssh remotehost xclip < myconf.conf


                    Why would it need to be modified with sed? ssh is transparent to data when not used as a terminal, and is commonly used in pipelines such as



                    tar cfz - somedir | ssh remotehost 'cd destdir; tar xfz -'`





                    share|improve this answer























                    • Is there a way to do it from within an existing SSH session? I'd really prefer not to have to open up another terminal window if I already have one open to the machine in question.

                      – Naftuli Kay
                      Jul 14 '11 at 23:56











                    • And sed` is just there as an example, if I'd like to perform any processing on the stdin before copying it to the clipboard, I'd like that option.

                      – Naftuli Kay
                      Jul 14 '11 at 23:57











                    • No, there's no way to inject data into an existing ssh session (it wouldn't be very secure if you could). You can set up the ssh ControlMaster stuff to multiplex additional connections over an existing one, but it's not really something for beginners and you still do it the same way afterward, by switching to another local terminal and running the command above (which does not open a new terminal window).

                      – geekosaur
                      Jul 15 '11 at 0:03















                    5














                    You don't need anything special; since xclip works over stdin, just



                    ssh remotehost xclip < myconf.conf


                    Why would it need to be modified with sed? ssh is transparent to data when not used as a terminal, and is commonly used in pipelines such as



                    tar cfz - somedir | ssh remotehost 'cd destdir; tar xfz -'`





                    share|improve this answer























                    • Is there a way to do it from within an existing SSH session? I'd really prefer not to have to open up another terminal window if I already have one open to the machine in question.

                      – Naftuli Kay
                      Jul 14 '11 at 23:56











                    • And sed` is just there as an example, if I'd like to perform any processing on the stdin before copying it to the clipboard, I'd like that option.

                      – Naftuli Kay
                      Jul 14 '11 at 23:57











                    • No, there's no way to inject data into an existing ssh session (it wouldn't be very secure if you could). You can set up the ssh ControlMaster stuff to multiplex additional connections over an existing one, but it's not really something for beginners and you still do it the same way afterward, by switching to another local terminal and running the command above (which does not open a new terminal window).

                      – geekosaur
                      Jul 15 '11 at 0:03













                    5












                    5








                    5







                    You don't need anything special; since xclip works over stdin, just



                    ssh remotehost xclip < myconf.conf


                    Why would it need to be modified with sed? ssh is transparent to data when not used as a terminal, and is commonly used in pipelines such as



                    tar cfz - somedir | ssh remotehost 'cd destdir; tar xfz -'`





                    share|improve this answer













                    You don't need anything special; since xclip works over stdin, just



                    ssh remotehost xclip < myconf.conf


                    Why would it need to be modified with sed? ssh is transparent to data when not used as a terminal, and is commonly used in pipelines such as



                    tar cfz - somedir | ssh remotehost 'cd destdir; tar xfz -'`






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 14 '11 at 23:55









                    geekosaurgeekosaur

                    22.5k25853




                    22.5k25853












                    • Is there a way to do it from within an existing SSH session? I'd really prefer not to have to open up another terminal window if I already have one open to the machine in question.

                      – Naftuli Kay
                      Jul 14 '11 at 23:56











                    • And sed` is just there as an example, if I'd like to perform any processing on the stdin before copying it to the clipboard, I'd like that option.

                      – Naftuli Kay
                      Jul 14 '11 at 23:57











                    • No, there's no way to inject data into an existing ssh session (it wouldn't be very secure if you could). You can set up the ssh ControlMaster stuff to multiplex additional connections over an existing one, but it's not really something for beginners and you still do it the same way afterward, by switching to another local terminal and running the command above (which does not open a new terminal window).

                      – geekosaur
                      Jul 15 '11 at 0:03

















                    • Is there a way to do it from within an existing SSH session? I'd really prefer not to have to open up another terminal window if I already have one open to the machine in question.

                      – Naftuli Kay
                      Jul 14 '11 at 23:56











                    • And sed` is just there as an example, if I'd like to perform any processing on the stdin before copying it to the clipboard, I'd like that option.

                      – Naftuli Kay
                      Jul 14 '11 at 23:57











                    • No, there's no way to inject data into an existing ssh session (it wouldn't be very secure if you could). You can set up the ssh ControlMaster stuff to multiplex additional connections over an existing one, but it's not really something for beginners and you still do it the same way afterward, by switching to another local terminal and running the command above (which does not open a new terminal window).

                      – geekosaur
                      Jul 15 '11 at 0:03
















                    Is there a way to do it from within an existing SSH session? I'd really prefer not to have to open up another terminal window if I already have one open to the machine in question.

                    – Naftuli Kay
                    Jul 14 '11 at 23:56





                    Is there a way to do it from within an existing SSH session? I'd really prefer not to have to open up another terminal window if I already have one open to the machine in question.

                    – Naftuli Kay
                    Jul 14 '11 at 23:56













                    And sed` is just there as an example, if I'd like to perform any processing on the stdin before copying it to the clipboard, I'd like that option.

                    – Naftuli Kay
                    Jul 14 '11 at 23:57





                    And sed` is just there as an example, if I'd like to perform any processing on the stdin before copying it to the clipboard, I'd like that option.

                    – Naftuli Kay
                    Jul 14 '11 at 23:57













                    No, there's no way to inject data into an existing ssh session (it wouldn't be very secure if you could). You can set up the ssh ControlMaster stuff to multiplex additional connections over an existing one, but it's not really something for beginners and you still do it the same way afterward, by switching to another local terminal and running the command above (which does not open a new terminal window).

                    – geekosaur
                    Jul 15 '11 at 0:03





                    No, there's no way to inject data into an existing ssh session (it wouldn't be very secure if you could). You can set up the ssh ControlMaster stuff to multiplex additional connections over an existing one, but it's not really something for beginners and you still do it the same way afterward, by switching to another local terminal and running the command above (which does not open a new terminal window).

                    – geekosaur
                    Jul 15 '11 at 0:03











                    4














                    Here's how you would do it on OSX from your local machine



                    ssh remotehost.com "<some/file.txt" | pbcopy





                    share|improve this answer



























                      4














                      Here's how you would do it on OSX from your local machine



                      ssh remotehost.com "<some/file.txt" | pbcopy





                      share|improve this answer

























                        4












                        4








                        4







                        Here's how you would do it on OSX from your local machine



                        ssh remotehost.com "<some/file.txt" | pbcopy





                        share|improve this answer













                        Here's how you would do it on OSX from your local machine



                        ssh remotehost.com "<some/file.txt" | pbcopy






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Apr 2 '13 at 14:07









                        William CasarinWilliam Casarin

                        1413




                        1413





















                            2














                            if your local machine is running windows(7+) you can just use this from the CommandLine:



                            ssh user@server cat /home/user/file | clip





                            share|improve this answer



























                              2














                              if your local machine is running windows(7+) you can just use this from the CommandLine:



                              ssh user@server cat /home/user/file | clip





                              share|improve this answer

























                                2












                                2








                                2







                                if your local machine is running windows(7+) you can just use this from the CommandLine:



                                ssh user@server cat /home/user/file | clip





                                share|improve this answer













                                if your local machine is running windows(7+) you can just use this from the CommandLine:



                                ssh user@server cat /home/user/file | clip






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Dec 5 '14 at 15:34









                                d.raevd.raev

                                1213




                                1213





















                                    1














                                    ~/.ssh/config:



                                    Host REMOTEHOST
                                    ...
                                    ForwardX11 yes


                                    /etc/ssh/sshd_config:



                                    X11Forwarding yes


                                    bash:



                                    $ xclip -o | ssh REMOTEHOST 'DISPLAY=:0 xclip -i'





                                    share|improve this answer



























                                      1














                                      ~/.ssh/config:



                                      Host REMOTEHOST
                                      ...
                                      ForwardX11 yes


                                      /etc/ssh/sshd_config:



                                      X11Forwarding yes


                                      bash:



                                      $ xclip -o | ssh REMOTEHOST 'DISPLAY=:0 xclip -i'





                                      share|improve this answer

























                                        1












                                        1








                                        1







                                        ~/.ssh/config:



                                        Host REMOTEHOST
                                        ...
                                        ForwardX11 yes


                                        /etc/ssh/sshd_config:



                                        X11Forwarding yes


                                        bash:



                                        $ xclip -o | ssh REMOTEHOST 'DISPLAY=:0 xclip -i'





                                        share|improve this answer













                                        ~/.ssh/config:



                                        Host REMOTEHOST
                                        ...
                                        ForwardX11 yes


                                        /etc/ssh/sshd_config:



                                        X11Forwarding yes


                                        bash:



                                        $ xclip -o | ssh REMOTEHOST 'DISPLAY=:0 xclip -i'






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Apr 4 '16 at 8:35









                                        superqwertysuperqwerty

                                        111




                                        111





















                                            0














                                            I have similar issue with LUbuntu's lxterminal (tested various terminals) pasting clipboard to an ssh session. If clipboard has more than about 100 bytes the session timeouts and fails.



                                            If I connect via ssh to almost any CentOS 5.x server and then connect to the target server, clipboard paste works without any issue for any reasonable data size.






                                            share|improve this answer





























                                              0














                                              I have similar issue with LUbuntu's lxterminal (tested various terminals) pasting clipboard to an ssh session. If clipboard has more than about 100 bytes the session timeouts and fails.



                                              If I connect via ssh to almost any CentOS 5.x server and then connect to the target server, clipboard paste works without any issue for any reasonable data size.






                                              share|improve this answer



























                                                0












                                                0








                                                0







                                                I have similar issue with LUbuntu's lxterminal (tested various terminals) pasting clipboard to an ssh session. If clipboard has more than about 100 bytes the session timeouts and fails.



                                                If I connect via ssh to almost any CentOS 5.x server and then connect to the target server, clipboard paste works without any issue for any reasonable data size.






                                                share|improve this answer















                                                I have similar issue with LUbuntu's lxterminal (tested various terminals) pasting clipboard to an ssh session. If clipboard has more than about 100 bytes the session timeouts and fails.



                                                If I connect via ssh to almost any CentOS 5.x server and then connect to the target server, clipboard paste works without any issue for any reasonable data size.







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Feb 22 '12 at 23:28









                                                Kevin

                                                27.2k106299




                                                27.2k106299










                                                answered Aug 5 '11 at 13:36









                                                VasylVasyl

                                                1




                                                1





















                                                    0














                                                    Very similar to @d-raev's and @william-casarin solutions, however, it is different so I'm sharing what worked for me.



                                                    The command:



                                                    ssh user@host cat <myconffile.conf | xclip -sel clip



                                                    Explanation:



                                                    This is using ssh to create a secure tunnel, login to user @ host or ip, then execute cat to print the contents of <myconffile.conf to stdout then piping that to the command xclip -sel clip on your local machine, which places the contents of <myconffile.conf into the clipboard on your local machine.



                                                    Real-world example usage:



                                                    I use this command structure for tasks such as pasting ssh keys into github (allowing a simple ctrl-V or paste selection after I run the command) on with Bash on Ubuntu 16.04 and 18.04. Check out man ssh, man cat, and man xclip for behavior and option details.






                                                    share|improve this answer



























                                                      0














                                                      Very similar to @d-raev's and @william-casarin solutions, however, it is different so I'm sharing what worked for me.



                                                      The command:



                                                      ssh user@host cat <myconffile.conf | xclip -sel clip



                                                      Explanation:



                                                      This is using ssh to create a secure tunnel, login to user @ host or ip, then execute cat to print the contents of <myconffile.conf to stdout then piping that to the command xclip -sel clip on your local machine, which places the contents of <myconffile.conf into the clipboard on your local machine.



                                                      Real-world example usage:



                                                      I use this command structure for tasks such as pasting ssh keys into github (allowing a simple ctrl-V or paste selection after I run the command) on with Bash on Ubuntu 16.04 and 18.04. Check out man ssh, man cat, and man xclip for behavior and option details.






                                                      share|improve this answer

























                                                        0












                                                        0








                                                        0







                                                        Very similar to @d-raev's and @william-casarin solutions, however, it is different so I'm sharing what worked for me.



                                                        The command:



                                                        ssh user@host cat <myconffile.conf | xclip -sel clip



                                                        Explanation:



                                                        This is using ssh to create a secure tunnel, login to user @ host or ip, then execute cat to print the contents of <myconffile.conf to stdout then piping that to the command xclip -sel clip on your local machine, which places the contents of <myconffile.conf into the clipboard on your local machine.



                                                        Real-world example usage:



                                                        I use this command structure for tasks such as pasting ssh keys into github (allowing a simple ctrl-V or paste selection after I run the command) on with Bash on Ubuntu 16.04 and 18.04. Check out man ssh, man cat, and man xclip for behavior and option details.






                                                        share|improve this answer













                                                        Very similar to @d-raev's and @william-casarin solutions, however, it is different so I'm sharing what worked for me.



                                                        The command:



                                                        ssh user@host cat <myconffile.conf | xclip -sel clip



                                                        Explanation:



                                                        This is using ssh to create a secure tunnel, login to user @ host or ip, then execute cat to print the contents of <myconffile.conf to stdout then piping that to the command xclip -sel clip on your local machine, which places the contents of <myconffile.conf into the clipboard on your local machine.



                                                        Real-world example usage:



                                                        I use this command structure for tasks such as pasting ssh keys into github (allowing a simple ctrl-V or paste selection after I run the command) on with Bash on Ubuntu 16.04 and 18.04. Check out man ssh, man cat, and man xclip for behavior and option details.







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Jan 11 at 21:34









                                                        Jason R Stevens CFAJason R Stevens CFA

                                                        34




                                                        34





















                                                            -1














                                                            https://secure.wikimedia.org/wikipedia/en/wiki/Base64



                                                            You can convert your clipboard data with Base64 to ASCII text. Then you can push that through inside an already existing SSH connection.






                                                            share|improve this answer

























                                                            • Why convert to anything? It's already text in this case and even if it was binary there would be no reason you couldn't send it across a pipeline like this.

                                                              – Caleb
                                                              Aug 2 '11 at 10:41











                                                            • clipboard could contain binary data, e.g.: a compiled application

                                                              – LanceBaynes
                                                              Aug 2 '11 at 14:34











                                                            • Yes it could, but why would that be a problem? Binary data can be transferred through a pipe and ssh tunnel.

                                                              – Caleb
                                                              Aug 2 '11 at 14:39















                                                            -1














                                                            https://secure.wikimedia.org/wikipedia/en/wiki/Base64



                                                            You can convert your clipboard data with Base64 to ASCII text. Then you can push that through inside an already existing SSH connection.






                                                            share|improve this answer

























                                                            • Why convert to anything? It's already text in this case and even if it was binary there would be no reason you couldn't send it across a pipeline like this.

                                                              – Caleb
                                                              Aug 2 '11 at 10:41











                                                            • clipboard could contain binary data, e.g.: a compiled application

                                                              – LanceBaynes
                                                              Aug 2 '11 at 14:34











                                                            • Yes it could, but why would that be a problem? Binary data can be transferred through a pipe and ssh tunnel.

                                                              – Caleb
                                                              Aug 2 '11 at 14:39













                                                            -1












                                                            -1








                                                            -1







                                                            https://secure.wikimedia.org/wikipedia/en/wiki/Base64



                                                            You can convert your clipboard data with Base64 to ASCII text. Then you can push that through inside an already existing SSH connection.






                                                            share|improve this answer















                                                            https://secure.wikimedia.org/wikipedia/en/wiki/Base64



                                                            You can convert your clipboard data with Base64 to ASCII text. Then you can push that through inside an already existing SSH connection.







                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited Jul 9 '15 at 17:36









                                                            Community

                                                            1




                                                            1










                                                            answered Jul 16 '11 at 8:22









                                                            LanceBaynesLanceBaynes

                                                            10.4k76196323




                                                            10.4k76196323












                                                            • Why convert to anything? It's already text in this case and even if it was binary there would be no reason you couldn't send it across a pipeline like this.

                                                              – Caleb
                                                              Aug 2 '11 at 10:41











                                                            • clipboard could contain binary data, e.g.: a compiled application

                                                              – LanceBaynes
                                                              Aug 2 '11 at 14:34











                                                            • Yes it could, but why would that be a problem? Binary data can be transferred through a pipe and ssh tunnel.

                                                              – Caleb
                                                              Aug 2 '11 at 14:39

















                                                            • Why convert to anything? It's already text in this case and even if it was binary there would be no reason you couldn't send it across a pipeline like this.

                                                              – Caleb
                                                              Aug 2 '11 at 10:41











                                                            • clipboard could contain binary data, e.g.: a compiled application

                                                              – LanceBaynes
                                                              Aug 2 '11 at 14:34











                                                            • Yes it could, but why would that be a problem? Binary data can be transferred through a pipe and ssh tunnel.

                                                              – Caleb
                                                              Aug 2 '11 at 14:39
















                                                            Why convert to anything? It's already text in this case and even if it was binary there would be no reason you couldn't send it across a pipeline like this.

                                                            – Caleb
                                                            Aug 2 '11 at 10:41





                                                            Why convert to anything? It's already text in this case and even if it was binary there would be no reason you couldn't send it across a pipeline like this.

                                                            – Caleb
                                                            Aug 2 '11 at 10:41













                                                            clipboard could contain binary data, e.g.: a compiled application

                                                            – LanceBaynes
                                                            Aug 2 '11 at 14:34





                                                            clipboard could contain binary data, e.g.: a compiled application

                                                            – LanceBaynes
                                                            Aug 2 '11 at 14:34













                                                            Yes it could, but why would that be a problem? Binary data can be transferred through a pipe and ssh tunnel.

                                                            – Caleb
                                                            Aug 2 '11 at 14:39





                                                            Yes it could, but why would that be a problem? Binary data can be transferred through a pipe and ssh tunnel.

                                                            – Caleb
                                                            Aug 2 '11 at 14:39

















                                                            draft saved

                                                            draft discarded
















































                                                            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%2f16694%2fcopy-input-to-clipboard-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

                                                            How to check contact read email or not when send email to Individual?

                                                            Bahrain

                                                            Postfix configuration issue with fips on centos 7; mailgun relay