This local loop interface only allows connections from your own machine (including, in this case, those reverse tunneled in via SSH). We do ncat -l localhost 10009 for the server, which means it listens only on the network interface with the localhost IP address. No need for xclip on the remote machine, so it works if you can't install it or can't use it because it's a headless server without X. No need to open another SSH session to the remote machine. We could call it rclip for " remote clipboard" in analogy to the well-known xclip. ssh -R 10008:localhost:10009 you want to copy a file's content from remote machine to local clipboard, execute in the SSH shell: ncat -send-only localhost 10008 < file.txtĪnd of course, that's nicer when packaged as a shell shortcut or script. You can use that SSH session for your normal work. SSH into the remote machine in such a way that a reverse tunnel is established from port 10008 of the remote machine to port 10009 on your local machine (where your server is listening). Or use the equivalent shorthand version: ncat -klc "xclip -sel c" localhost 10009 On your local machine, set up a server listening on the local interface that will copy content coming in on port 10009 to your X clipboard: ncat -keep-open -listen -sh-exec "xclip -selection clipboard" localhost 10009 (On your remote machine you can also do with nc or plain telnet, but on the local machine we need the options to execute commands ( -c / -e) which are not available in nc in usual distributions like Debian and Ubuntu.) apt install nmap Install ncat on your local and remote machine. Copying from a headless server to local clipboard, from inside your usual SSH session:
0 Comments
Leave a Reply. |