copy from file and paste in the terminal without x server

blu*_*ylo 2 bash terminal console

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:

[SECRET KEY IN BASE64 REDACTED]
Run Code Online (Sandbox Code Playgroud)

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).
 (Q)uit.
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): 
Run Code Online (Sandbox Code Playgroud)

thank you folks!

小智 5

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

I
(the key goes here)
Run Code Online (Sandbox Code Playgroud)

and run your command again like this:

cmd < myinput
Run Code Online (Sandbox Code Playgroud)

上面的小于号会将“myfile”的内容发送到您的命令,就像在键盘上输入一样。

如果您的命令实际上是一个 shell 脚本,您也可以剖析它并找出如何将您的密钥直接提交给底层程序。