0

Basically I want to remotely cat a file, this is what I have so far. It doesn't work. I'm fairly new to all this:

echo /root/.ssh/id_rsa.pub | ssh root@HOSTNAME "cat >> /root/.ssh/authorized_keys
1

2 Answers 2

1

do not use echo, use cat

cat /root/.ssh/id_rsa.pub | ssh root@HOSTNAME "cat >> /root/.ssh/authorized_keys"
  • echo /root/.ssh/id_rsa.pub will output the string /root/.ssh/id_rsa.pub
  • cat /root/.ssh/id_rsa.pub will output the content of /root/.ssh/id_rsa.pub

  • ssh-copy-id -i my/alternate/pub.key root@HOSTNAME might be a solution, you will be asked password the first time.

0

After setting trusts between servers with you can cat a file with ssh command

ssh-keygen -t rsa
ssh-copy-id [email protected]
ssh -l username server.ip.addr "cat file.txt"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .