I have 2 machine machine1 and machine2.
I want to write from write some contents into file in machine2 from machine1.
In a same machine I can run sudo cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
to write the contents of ~/.ssh/id_dsa.pub
into ~/.ssh/authorized_keys
file.
But I want to contents of ~/.ssh/id_dsa.pub
machine1 into ~/.ssh/authorized_keys
file in machine2. I can do ssh and do this.
Since I'm installing hadoop in a silent mode in single command with username and password.
I don't want to do scp
which replaces the whole file.
How can I do it in a single command supplying with username/password of another machine.
ssh user@machine2 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_dsa.pub
. But you don't need that. Usessh-copy-id
instead.sudo cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
There is no point usingsudo
there, you should avoid using sudo unless you actually need it.