5

I have ssh'ed into a Linux console using the Cygwin ssh command. after running a command I need to copy several lines of the output and paste them into a windows notepad window.

The problem is that I cannot use the mouse in my ssh session because I am blind, so left-clicking and dragging to the bottom of the area to copy won't work for me.

Are there any keyboard ways to accomplish this?

BTW: I am trying to copy a 3 or 4 line randomly generated activation key for some software which I need to save.

An addition to this question is the command I am running presents this long activation key which actually has to be pasted into a website to generate a token which then has to be pasted into the terminal which is waiting for input after displaying the activation key.

I know I can use the right-click or ctrl+ins keys to paste the token back into the terminal, but I need to get the activation key.

Redirecting to a file won't work because of the second step of the process.

5
  • This is a MS-windows question, it has nothing to do with Unix or ssh, as these are not the components involved with the cut/copy. If you are running the ssh in a cmd window, then I believe that there is an option in the edit menu. Also in options you can enable quick-???? (can't remember the name) it allows you to select right click to copy, and right click to paste (or paste it somewhere else e.g. notepad). This is nearly as quick as the X11 select, then middle button to paste. Feb 2 '17 at 23:04
  • Oh I just read the 2nd paragraph, so my suggestion above will not work for you. I do not know the details (as I use emacs), but I believe that the vi editor would make life easier for you. It is a bit hard to learn, but very powerful, and does not use a GUI type interface. Feb 2 '17 at 23:08
  • You can also use scp part of ssh. It is a file copy command, it will allow you to copy a file from the remote to the local. It also uses same authentication as ssh, so if you have ssh access, you should have scp access. Example scp user@remote-host:/path/to/file local-file-name Feb 2 '17 at 23:12
  • @Richard, vi is a reasonable solution, but I am not sure how it would work in this case. I have been using vi for almost 20 years, although I am by no means an expert :)
    – dnraikes
    Feb 2 '17 at 23:23
  • The vi answer was focussing on getting the text in to a usable editor, that is usable by a blind person. I did not think about why you where doing it. This is why I added the scp answer, as it may be more use full for this particular problem. Feb 3 '17 at 17:58
2

There is a keyboard shortcut - Alt-Space will open the Control menu for the active window, which will have an Edit sub-menu. Mark will allow you to select an area, and the Enter key will copy the selection to the clipboard for pasting elsewhere. I do not know the keyboard shortcuts for demarking the selected area to be copied, and unfortunately do not have a Windows machine to hand upon which to experiment.

If the text you need to copy is the output of a command, you could redirect the output into a file (e. g. /path/to/sometool > myfile.txt) and then open that file in Notepad directly.

3
  • @dopghoti, This is very workable provided the ssh session is originating from a windows system. I actually used the context menu for the window, selected edit -> select all, then <enter> to copy to the clipboard.
    – dnraikes
    Feb 3 '17 at 20:10
  • However, what if the host originating the ssh session is a *nix system, does it have similar keyboard functions to copy the entire console window into a clipboard?
    – dnraikes
    Feb 3 '17 at 20:16
  • If you are within a *nix GUI environment, there may be such a keyboard shortcut, but that would depend upon the actual window manager in question (e. g. Gnome, KDE, twm, lxde, et cetera).
    – DopeGhoti
    Feb 3 '17 at 21:09
1

To get a file from a remote machine that you have access to via ssh, and usable via a not visual interface.

You can use scp part of ssh. It is a file copy command, it will allow you to copy a file from the remote to the local. It also uses same authentication as ssh, so if you have ssh access, you should have scp access.

Example scp user@remote-host:/path/to/file local-file-name

Note both arguments can be local or remote.

1
  • Once again this is a good idea except that I am in the middle of an interactive application that simply displays one thing on the console that has to be copied and pasted into a browser and the response from the browser pasted back into the interactive application running in the console.
    – dnraikes
    Feb 3 '17 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.