[dundee] Pushing SSH Certs
Rick Moynihan
rick.moynihan at gmail.com
Fri Nov 27 10:24:35 UTC 2009
Here's a great function I just found whilst digging around some bash configs.
It pushes your ssh public key to the specified hosts (for passwordless
login) and if there isn't an ssh keypair on your box, it'll create
one. This is one of those utility functions that I've been meaning to
write for years.... With the proliferation of servers and VM's I deal
with this is gonna be mega handy.
# Push SSH public key to remote servers
push_ssh_cert() {
local _host
test -f ~/.ssh/id_rsa.pub || ssh-keygen -t rsa
for _host in "$@";
do
echo $_host
ssh $_host 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_rsa.pub
done
}
You know the drill... drop it in your .bashrc, resource with .
~/.bashrc and run like so:
rick at lechuck:~ $ push_ssh_cert blackbeard.local
Anybody got any other handy bash snippets?
R.
More information about the dundee
mailing list