How can I append to a file remotely using a linux command (via ssh keys)
This is what I have so far:
Code:
ssh root@server1 "echo '55.55.55.55 ssh-rsa AAAABasdfaser45234234asdfasdfR0PxE' >>/root/.ssh/known_hosts"
I also tried:
Code:
ssh root@server1 `echo "55.55.55.55 ssh-rsa AAAABasdfaser45234234asdfasdfR0PxE" >>/root/.ssh/known_hosts`
and both are giving the error:
Code:
sh: /root/.ssh/known_hosts: Permission denied
And also I tried:
Code:
ssh root@server1 `echo 55.55.55.55 ssh-rsa AAAABasdfaser45234234asdfasdfR0PxE` >>/root/.ssh/known_hosts
Which gives the error:
Code:
-bash: command substitution: line 1: unexpected EOF while looking for matching `"'
-bash: command substitution: line 2: syntax error: unexpected end of file
-bash: /root/.ssh/known_hosts: Permission denied
Which means it sounds like its trying to execute /root/.ssh/known_hosts instead of writing to it.
TIA