我想用 GitHub Action 远程登录服务器更新网站,但没法成功,SSH 命令不能识别我的私钥。有没有大佬能帮忙看一下。
我用的命令是:
echo "$SSH_PRIVATE_KEY" > id_rsa
chmod 600 id_rsa
ssh-keygen -y -f id_rsa | tail -c 48 # 用私钥生成公钥,截取最后一段。
ssh "suse-zh@$SSH_SERVER_ADDRESS" -p38324 -v -i id_rsa < utils/git-pull.sh
输出是
fTRrtWKZwiWfm5qyN7pddPc= suse-zh@github-actions
^ 用私钥生成公钥,截取最后一段。这里就可以看出我的私钥没问题
OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
Pseudo-terminal will not be allocated because stdin is not a terminal.
debug1: Connecting to *** [***] port 38324.
debug1: Connection established.
debug1: SELinux support disabled
debug1: identity file id_rsa type -1
^ 没有识别,类型为-1 就是不存在
debug1: identity file id_rsa-cert type -1