Skip to content

Instantly share code, notes, and snippets.

@paramah
Created November 4, 2012 15:42
Show Gist options
  • Save paramah/4012341 to your computer and use it in GitHub Desktop.
Save paramah/4012341 to your computer and use it in GitHub Desktop.

Revisions

  1. paramah created this gist Nov 4, 2012.
    22 changes: 22 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/bin/sh

    KEY="$HOME/.ssh/identity.pub"

    if [ ! -f ~/.ssh/identity.pub ];then
    echo "private key not found at $KEY"
    echo "* please create it with "ssh-keygen -t dsa" *"
    echo "* to login to the remote host without a password, don't give the key you create with ssh-keygen a password! *"
    exit
    fi

    if [ -z $1 ];then
    echo "Please specify [email protected] as the first switch to this script"
    exit
    fi

    echo "Putting your key on $1... "

    KEYCODE=`cat $KEY`
    ssh -q $1 "mkdir ~/.ssh 2>/dev/null; chmod 700 ~/.ssh; echo "$KEYCODE" >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys"

    echo "done!"