#!/bin/sh # ssh-uploadkeys 0.9 - create and upload ssh key for passworldless authentication # unlike other ssh key uploaders, ssh-uploadkeys asks password only once. # (c) GPL Tero Karvinen http://www.iki.fi/karvinen # 2005-11-19 Merged "too much rights for .ssh" bugfix from Ville Myllymaki # 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/ && chmod 0700 $HOME/.ssh/ && cat tero-authorized_keys >> .ssh/authorized_keys && chmod 0600 .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. If you think it is bug, send me a quick feedback http://www.iki.fi/karvinen/contact.html."' fi # Using octal notation in chmod to set all permissions explicitly. read=4 write=2 execute=1 # End of ssh-uploadkeys