Copy input to clipboard over SSH?
Clash Royale CLAN TAG#URR8PPP
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
add a comment |
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
add a comment |
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
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
ssh xorg clipboard
asked Jul 14 '11 at 23:41
Naftuli KayNaftuli Kay
12.3k56158252
12.3k56158252
add a comment |
add a comment |
8 Answers
8
active
oldest
votes
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
.
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
add a comment |
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 -'`
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 thestdin
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 existingssh
session (it wouldn't be very secure if you could). You can set up thessh
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
add a comment |
Here's how you would do it on OSX from your local machine
ssh remotehost.com "<some/file.txt" | pbcopy
add a comment |
if your local machine is running windows(7+) you can just use this from the CommandLine:
ssh user@server cat /home/user/file | clip
add a comment |
~/.ssh/config:
Host REMOTEHOST
...
ForwardX11 yes
/etc/ssh/sshd_config:
X11Forwarding yes
bash:
$ xclip -o | ssh REMOTEHOST 'DISPLAY=:0 xclip -i'
add a comment |
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.
add a comment |
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.
add a comment |
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.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
.
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
add a comment |
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
.
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
add a comment |
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
.
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
.
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
add a comment |
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
add a comment |
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 -'`
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 thestdin
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 existingssh
session (it wouldn't be very secure if you could). You can set up thessh
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
add a comment |
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 -'`
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 thestdin
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 existingssh
session (it wouldn't be very secure if you could). You can set up thessh
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
add a comment |
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 -'`
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 -'`
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 thestdin
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 existingssh
session (it wouldn't be very secure if you could). You can set up thessh
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
add a comment |
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 thestdin
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 existingssh
session (it wouldn't be very secure if you could). You can set up thessh
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
add a comment |
Here's how you would do it on OSX from your local machine
ssh remotehost.com "<some/file.txt" | pbcopy
add a comment |
Here's how you would do it on OSX from your local machine
ssh remotehost.com "<some/file.txt" | pbcopy
add a comment |
Here's how you would do it on OSX from your local machine
ssh remotehost.com "<some/file.txt" | pbcopy
Here's how you would do it on OSX from your local machine
ssh remotehost.com "<some/file.txt" | pbcopy
answered Apr 2 '13 at 14:07
William CasarinWilliam Casarin
1413
1413
add a comment |
add a comment |
if your local machine is running windows(7+) you can just use this from the CommandLine:
ssh user@server cat /home/user/file | clip
add a comment |
if your local machine is running windows(7+) you can just use this from the CommandLine:
ssh user@server cat /home/user/file | clip
add a comment |
if your local machine is running windows(7+) you can just use this from the CommandLine:
ssh user@server cat /home/user/file | clip
if your local machine is running windows(7+) you can just use this from the CommandLine:
ssh user@server cat /home/user/file | clip
answered Dec 5 '14 at 15:34
d.raevd.raev
1213
1213
add a comment |
add a comment |
~/.ssh/config:
Host REMOTEHOST
...
ForwardX11 yes
/etc/ssh/sshd_config:
X11Forwarding yes
bash:
$ xclip -o | ssh REMOTEHOST 'DISPLAY=:0 xclip -i'
add a comment |
~/.ssh/config:
Host REMOTEHOST
...
ForwardX11 yes
/etc/ssh/sshd_config:
X11Forwarding yes
bash:
$ xclip -o | ssh REMOTEHOST 'DISPLAY=:0 xclip -i'
add a comment |
~/.ssh/config:
Host REMOTEHOST
...
ForwardX11 yes
/etc/ssh/sshd_config:
X11Forwarding yes
bash:
$ xclip -o | ssh REMOTEHOST 'DISPLAY=:0 xclip -i'
~/.ssh/config:
Host REMOTEHOST
...
ForwardX11 yes
/etc/ssh/sshd_config:
X11Forwarding yes
bash:
$ xclip -o | ssh REMOTEHOST 'DISPLAY=:0 xclip -i'
answered Apr 4 '16 at 8:35
superqwertysuperqwerty
111
111
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited Feb 22 '12 at 23:28
Kevin
27.2k106299
27.2k106299
answered Aug 5 '11 at 13:36
VasylVasyl
1
1
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Jan 11 at 21:34
Jason R Stevens CFAJason R Stevens CFA
34
34
add a comment |
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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