Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

marcel (3299)

marcel
  (email not shown publicly)

Journal of marcel (3299)

Tuesday July 23, 2002
08:02 AM

SSH authentication

[ #6571 ]

I just got fed up with having to enter the password for ssh connections time and again. Of course, it's a simple matter of copying a few files and setting a few permissions, but I just can't remember the exact things to do. So here you go: just create a key with

        ssh-keygen -t dsa

and run this script:

#!/bin/sh
# rhive.sh - create remote hive (well, RSA authentication).
# $1 needs to be 'user@host'. Need to enter password two or three times.

echo 'Creating remote .ssh directory...'
ssh $1 'mkdir -p ~/.ssh && chmod 700 ~/.ssh'

if [ -f ~/.ssh/identity.pub ] ; then
        echo 'Transferring identity.pub -> known_hosts...'
        scp ~/.ssh/identity.pub $1:~/.ssh/known_hosts
fi

if [ -f ~/.ssh/id_dsa.pub ] ; then
        echo 'Transferring id_dsa.pub -> authorized_keys2...'
        scp ~/.ssh/id_dsa.pub $1:~/.ssh/authorized_keys2
fi

echo 'Setting permissions on public keys...'
ssh $1 'chmod 600 ~/.ssh/*'

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • if [ -f ~/.ssh/identity.pub ] ; then
            echo 'Transferring identity.pub -> known_hosts...'
            scp ~/.ssh/identity.pub $1:~/.ssh/known_hosts
    fi

    I think you mean identity.pub -> .ssh/authorised_keys here

    if [ -f ~/.ssh/id_dsa.pub ] ; then
            echo 'Transferring id_dsa.pub -> authorized_keys2...'
            scp ~/.ssh/id_dsa.pub $1:~/.ssh/authorized_keys2
    fi

    Ow, you just blatted the ssh public key that was alrea