When it is a question of setting up things on remote machine, I managed always to get job done with a python script I wrote ( ssh + expect ). But I found these 2 shell scripts from Shannon -jj Behrens very useful.
The first installs your ssh-key on remote server:
# Install my ssh key on a remote system.
ssh-installkey() {
[ -n "$1" ] || {
echo "usage: ssh-installkey username@host" >&2
return 1
}
ssh $1 "mkdir -p -m 700 .ssh"
ssh $1 "cat >> ~/.ssh/authorized_keys2" < ~/.ssh/id_dsa.pub
}

The second copies your local settings to the remote machine. Adapt it to your need. For me the most important settings are those for vi (the .vimrc file).
# Install some basic settings on the remote system for things like zsh, vim,
# and screen. Then, try to change shells.
ssh-installsettings() {
[ -n "$1" ] || {
echo "usage: ssh-installsettings username@host" >&2
return 1
}
scp -r \
.zlogin .zshenv .zshrc \
.vim .vimrc \
.screenrc \
$1:
echo "Attempting to set login shell." >&2
ssh $1 "chsh -s /usr/bin/zsh"
}