简体   繁体   中英

Git keeps asking for my password after doing ssh-add

Hi Git keeps asking for my password even after I followed https://unix.stackexchange.com/questions/12195/how-to-avoid-being-asked-passphrase-each-time-i-push-to-bitbucket and ran ssh-add

I added the following to my .bashrc

# http://stackoverflow.com/questions/10032461/git-keeps-asking-me-for-my-ssh-key-pas$
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

I just started programming, and have set up a blank ubuntu instance from scratch. However, I did add my id_rsa.pub to bitbucket already

Any help appreciated, ty

First, does your private ssh key has a passphrase? Because if it has not, ssh-agent is not needed.

Second, you can debug ssh with ssh -Tv git@bitbucket.org and see what is going on. You could have permission issue for instance.

Third, as commented, is git remote -v returns https url, ssh would not be involved. At all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM