I have got an Ubuntu Linux without x server installed on it (because it's only a gateway). I am requested by an application (ossec,-my question is not ossec related-) to paste information into the terminal. I have got the info in a file in ~/. the information to paste is:


I do not know how to paste it.

Here is what I have got:

* OSSEC HIDS v2.8 Agent manager.        *
* The following options are available:  *

 (I)mport key from the server (I).
Choose your action: I or Q: I

*Provide the key generated by the server.
* The best approach is to cut and paste it. 
*** OBS: do not include spaces or new lines. 

Paste it here (or '\q' to quit): 

thank you folks!

  • 3
    Since you revealed it to the entire internet, you need to destroy and re-create that key now (unless it's a public key, but it sounds like it isn't). – zwol Jul 28 '15 at 18:37
  • 1
    even though it's redacted, the key is available to anyone by looking at the edit history of the question. You should follow @zwol's advice. – drs Jul 28 '15 at 21:04
  • @drs I flagged the question (and the answer below that repeated the key) for a moderator to maybe lock out access to the edit history. Shoulda done that hours ago, thanks for the reminder. – zwol Jul 29 '15 at 3:07

Use gpm. You can install it with

sudo apt-get install gpm

Once that is finished, you will have a working mouse. Now you can cat the file that contains your data, select it and then paste it with the middle mouse button.

Assuming, of course, that you have a mouse.


Looks like redirecting standard input may work for you. Try creating a file (named 'myinput') with two lines:

(the key goes here)

and run your command again like this:

cmd < myinput

The less-than sign above will send the contents of 'myfile' to your command as if it was typed on the keyboard.

If your command is actually a shell script you may also be able to dissect it and figure out how to submit your key directly to the underlying program.

  • The first line answers the first question "import or quit", the second supplies the key. Both lines should end with newline characters. – duanev Jul 28 '15 at 16:11
  • Yes, sorry, I had missed that the program read input twice. I saw and deleted my comment. – terdon Jul 28 '15 at 16:13

Have a look on how screen or tmux do cut'n'paste. Both mimic cut'n'paste using cursor keys and some other command keys, so this will work wherever you can start screen or tmux. No real mouse is needed, will work via ssh too...


If you have physical access to that server's text console and a mouse is attached, read about gpm which will give you a mouse for the text consoles which can do cut'n'paste as usual.

In this context screen or tmux will work too. It's never a mistake to know at least one of them...

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.