Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- if [ "$1" == "" ]; then
- echo Enter the box name Eg: machinexyz.machinehost.com
- read stagename
- else
- stagename=$1
- fi
- temp=`ls /usr/bin | grep ssh.exe| wc -l`;
- if [ $temp == 0 ]; then
- echo Please install ssh in cygwin
- echo While installing cygwin, enable Openssh* options under Net
- fi
- temp=`ls /usr/bin | grep scp.exe| wc -l`;
- if [ $temp == 0 ]; then
- echo Please install scp in cygwin
- fi
- # Cleanup just in case
- if [ -f ~/.ssh/passwordless_key ]; then
- rm ~/.ssh/passwordless_key
- fi
- # Check if the key already exists
- # If so copy it to passwordless_key
- if [ -f ~/.ssh/id_dsa.pub ]; then
- cp ~/.ssh/id_dsa.pub ~/.ssh/passwordless_key
- elif [ -f ~/.ssh/id_rsa.pub ]; then
- cp ~/.ssh/id_rsa.pub ~/.ssh/passwordless_key
- elif [ -f ~/.ssh/identity.pub ]; then
- cp ~/.ssh/identity.pub ~/.ssh/passwordless_key
- fi
- # If not, create it
- if [ ! -f ~/.ssh/passwordless_key ]; then
- echo Generating key
- ssh-keygen -t dsa -f ~/.ssh/id_dsa -N ''
- cp ~/.ssh/id_dsa.pub ~/.ssh/passwordless_key
- fi
- # Copy the public key to the stage
- #scp ~/.ssh/passwordless_key $stagename:~/.ssh/authorized_keys
- cat ~/.ssh/passwordless_key | ssh $stagename "mkdir -m 0700 -p .ssh && cat - >> .ssh/authorized_keys && chmod 0600 .ssh/authorized_keys"
- # Cleanup
- rm ~/.ssh/passwordless_key
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement