How to send data to local clipboard from a remote SSH session

前端 未结 11 1440
别那么骄傲
别那么骄傲 2020-12-07 07:29

Borderline ServerFault question, but I\'m programming some shell scripts, so I\'m trying here first :)

Most *nixes have a command that will let you pipe/red

11条回答
  •  孤街浪徒
    2020-12-07 07:51

    Reverse tunnel port on ssh server

    All the existing solutions either need:

    • X11 on the client (if you have it, xclip on the server works great) or
    • the client and server to be in the same network (which is not the case if you're at work trying to access your home computer).

    Here's another way to do it, though you'll need to modify how you ssh into your computer.

    I've started using this and it's nowhere near as intimidating as it looks so give it a try.

    Client (ssh session startup)

    ssh username@server.com -R 2000:localhost:2000
    

    (hint: make this a keybinding so you don't have to type it)

    Client (another tab)

    nc -l 2000 | pbcopy
    

    Note: if you don't have pbcopy then just tee it to a file.

    Server (inside SSH session)

    cat some_useful_content.txt | nc localhost 2000
    

    Other notes

    Actually even if you're in the middle of an ssh session there's a way to start a tunnel but i don’t want to scare people away from what really isn’t as bad as it looks. But I'll add the details later if I see any interest

提交回复
热议问题