[CentOS] ssh-askpass in bash script

Sun Mar 2 13:57:55 UTC 2014
Tim Dunphy <bluethundr at gmail.com>

Hey all,

 I have ssh-askpass installed on Centos 5.7 and I'm trying to find a way to
log into the host and not have it ask me to enter in my long / complex
passphrase every time I ssh into another host.

I've googled for some scripts that you can add to your bash configuration
so that you won't have to do that.

So I have to end up typing 'eval $(ssh-agent) &&  ssh-add' and enter in my
passphrase every time. It's a little annoying. I've been dealing with this
for a while and I could use some help.

Here's my bashrc file with the lines on using ssh-agent and ssh-add in it:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
SSH_ENV=$HOME/.ssh/env-$HOSTNAME

function ssh_clean {
    d="$HOME/.ssh"

    f0=$d/known_hosts
    f1=$d/known_hosts_tmp

    cat /dev/null > $f1

    while read host line; do
        if [ $host != "localhost" ]; then
            echo $host $line >> $f1
        fi
    done < $f0

    mv $f1 $f0

    chmod 644 $f0
}


# Initialize new agent and add authentication
function start_agent {

    echo "Initialising new SSH agent on $HOSTNAME  on $(date)" >> ~/agent

    # Start authenticating daemon
    # No authentications set up yet, just starting daemon!
    ssh-agent | head -2 > ${SSH_ENV}
    chmod 600 ${SSH_ENV}

    # Find SSH_AUTH_SOCK and SSH_AGENT_PID of the available daemon
    . ${SSH_ENV} > /dev/null

    # Add authentication to this and only this daemon
    ssh-add
}


if [ -f "$SSH_ENV" ]; then
    # Find SSH_AUTH_SOCK and SSH_AGENT_PID of the available daemon
    . ${SSH_ENV} > /dev/null

    # Check if the agent is still running
    ierr=0
    ps ${SSH_AGENT_PID} > /dev/null || ierr=1

    if [ $ierr == "0" ]; then
        echo > /dev/null
    else
        # If not initialize new agent and
        # add authentication
        start_agent;
    fi
else
    start_agent;
fi

export
PATH=$PATH:/home/iloshakov:/home/tdineen/eporter:/home/mrupapara:/home/tdunphy/bin:/home/ashoykhet:/home/tdineen/eporter
export PUB='/homeuser/.ssh/id_rsa.pub'


I'd appreciate any advice you may have!

Thanks

Tim

-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B