Append Text To Remote Servers File Via SSH

Gentleman & Ladies,

Please make me feel like and novice and explain why this is not working?

I am attempting to ssh to a remote server via ssh and keys. I want to inject a file on the remote server with text.

I am not achieving this. I would like to echo/inject the text on the remote server with a variable.

[root@radio5 bin]# ssh root@forums1.nyc /bin/echo $var  >> /root/filetobeinjected

Please let me know what I am doing wrong. The above code does not error, however it is not injecting text to the target file.

ABACUS

Quote your command.

That is,

ssh root@192.168.1.205 "/bin/echo $var >> /tmp/a"

If you dont do, it will redirect the output of the command to your local server, so the local server will have created targetfile earlier.

More clearly, the command will be executed in the remote server, and the output is redirected to the local server, to avoid that quote the command you want to execute.