
Hi again everyone. In my continuing quest to automate absolutely everything about rebuilding one of my computers, I'm writing a script that will generate a key relationship between it and my laptop (which I use for remote backup sometimes). I'm able to create the public and private keys without problems, but when it gets to adding the public key to the laptop ("scarlet"), I run into an issue. I don't want to just copy the public key into ~/.ssh/authorized_keys2 on scarlet, because from an aesthetic point of view, and a portability point of view, that's just nasty. If authorized_keys2 exists already, I'll overwrite it and cause myself pain. So, I instead copy the public key into my home dir on scarlet (scp ~/.ssh/id_dsa.pub bnonn(a)scarlet:~/) However, I then want to append the contents of this key to the authorized_keys2 file in ~/.ssh/ on scarlet. Seems to me that the best way to do this is to simply cat it, since this will create the file if it doesn't already exist. I'm using the following command: ssh bnonn(a)scarlet cat ~/id_dsa.pub >> ~/.ssh/authorized_keys2 This, however, appears to have no effect at all. It doesn't return an error; it just quietly does nothing. Again, I apologize if this is again an example of my fundamental dimness, but any help would be appreciated. Regards, Bnonn

PS. I'm not sure how clear I was in explaining, so if looking at the script itself will help, it's at <http://bnonn.ath.cx/bnonn/b.keypair> Please don't beat me if it's howwbly malformed or breaks some convention I don't know about \:

On Fri, 2005-12-09 at 09:51 +1300, Bnonn wrote:
ssh bnonn(a)scarlet cat ~/id_dsa.pub >> ~/.ssh/authorized_keys2
The redirection is happening on your localhost not on scarlet. ssh bnonn(a)scarlet "cat ~/id_dsa.pub >> ~/.ssh/authorized_keys2" will do what you want. You may want to check your authorized_keys2 file on your localhost as it might have some junk in it. Debian can do all this automatically via a little utility called ssh-copy-id. Simply call ssh-copy-id <hostname> And it will do everything :) Did I mention that Debian/Ubuntu rock? HTH -- Matt Brown matt(a)mattb.net.nz Mob +64 275 611 544 www.mattb.net.nz

Matt Brown wrote:
The redirection is happening on your localhost not on scarlet.
Figures. I always get the "where it's happening" bit wrong.
ssh bnonn(a)scarlet "cat ~/id_dsa.pub >> ~/.ssh/authorized_keys2" will do what you want.
Thanks (:
Debian can do all this automatically via a little utility called ssh-copy-id. Simply call
Even better...
Did I mention that Debian/Ubuntu rock?
Most certainly you are preaching to the converted, sir (:

On Fri, 2005-12-09 at 10:07 +1300, Bnonn wrote:
Matt Brown wrote:
The redirection is happening on your localhost not on scarlet.
Figures. I always get the "where it's happening" bit wrong.
ssh bnonn(a)scarlet "cat ~/id_dsa.pub >> ~/.ssh/authorized_keys2" will do what you want.
Thanks (:
One thing I forgot to mention. The above command assumes you have already scp'd id_dsa.pub to the remote host. If you haven't done that you probably want a command like cat ~/id_dsa.pub | ssh bnonn(a)scarlet "cat >> .ssh/authorized_keys" If you look at the source for ssh-copy-id (it's a 50 line bash script) you'll see that's basically all it does :) -- Matt Brown matt(a)mattb.net.nz Mob +64 275 611 544 www.mattb.net.nz
participants (2)
-
Bnonn
-
Matt Brown