« Back to Index

gpg-agent across vm ssh sessions

View original Gist on GitHub

gpg-agent across vm ssh sessions.sh

which gpg-agent && {
    gpg_agent_info_path="${HOME}/.gpg-agent-info"
    if [ -f "$gpg_agent_info_path" ]; then
        echo "using existing gpg agent"
        . "${HOME}/.gpg-agent-info"
        export GPG_AGENT_INFO
    else
        echo "starting gpg agent"
        eval $(gpg-agent --daemon --write-env-file "$gpg_agent_info_path")
    fi
}