Save ssh passphrase


To sace the passphrase and only enter it once add this to your .bashrc

SSH_ENV=$HOME/.ssh/environment

 

# start the ssh-agent

function start_agent {

    echo "Initializing new SSH agent..."

    # spawn ssh-agent

    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"

    echo succeeded

    chmod 600 "${SSH_ENV}"

    . "${SSH_ENV}" > /dev/null

    /usr/bin/ssh-add

}

 

if [ -f "${SSH_ENV}" ]; then

     . "${SSH_ENV}" > /dev/null

     ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {

        start_agent;

    }

else

    start_agent;

fi

After this you can logout and login aggain and will be asked for your passphrase. This will be saved and used for each connection to new servers

,

Leave a Reply

Your email address will not be published. Required fields are marked *