#!/bin/sh # ssh-uploadkeys - create and upload ssh key for passworldless authentication # unlike other ssh key uploaders, ssh-uploadkeys asks password only once. # (c) GPL Tero Karvinen # 2004-11-12 tested: works on Debian 3.0 Woody & MacOS X 10.3 (Thomas Kollbach) # 2003-11-15 bug: does not work with fedora fix: chmod og-rwx authorized_keys # 2003-10-30 beta release # http://iki.fi/karvinen tero.karvinen atsign iki.fi # Requires openssh and sh. Tested with Redhat 9. # put this into /usr/local/bin/ssh-uploadkeys or $HOME/bin/ssh-uploadkeys # then chmod a+x ssh-uploadkeys if [ -z "$1" ]; then echo "usage: ssh-uploadkeys user@host" else if [ -e "$HOME/.ssh/id_dsa.pub" ]; then echo "SSH public key found: ~/.ssh/id_dsa.pub" else echo -e '\n\n'|ssh-keygen -t dsa -N '' fi cat ~/.ssh/id_dsa.pub| \ ssh $1 'cat > tero-authorized_keys && mkdir -p $HOME/.ssh/ && cat tero-authorized_keys >> .ssh/authorized_keys && chmod og-rwx .ssh/authorized_keys && rm tero-authorized_keys && echo "Success, next time you do not need to type password."||echo "SSH key generation or upload failed."' fi # End of ssh-uploadkeys