The server is configured with gitlab's sshkey. You still need to enter a password when using SSH to pull code.

Phenomenon: I have generated sshkey on the server and uploaded it to gitlab, but when I use SSH to pull the code on the server, I still need to enter the password.

The reasons are as follows:
I am using a mobile cloud server, which is not turned on by default ssh-agent. If I want it to be turned on automatically every time I log in to the server, I need to ~/.bashrcadd the following configuration to the file:

if [ -z "$SSH_AUTH_SOCK" ] ; then
    eval $(ssh-agent -s)   # 每次登录服务器,都开启 ssh-agent
fi
ssh-add ~/.ssh/ssl_git_002  # 将我生成的 git 的私钥添加到 环境变量

Guess you like

Origin blog.csdn.net/fth1002853070/article/details/134665480