生成后无法将Vue CLI应用程序推送到github.io-权限被拒绝(公钥)



我已排除故障https://help.github.com/en/github/authenticating-to-github/error-permission-denied-publickey

  1. sudo命令应该与Git一起使用吗

我没有将sudo与我的git命令一起使用

  1. 检查您是否连接到了正确的服务器

运行$ ssh -vT git@github.com在端口22上建立连接并返回You've successfully authenticated

  1. 始终使用"git"用户

我已经使用set url命令将repo更改为使用SSH协议,并且ssh -T git@github.com返回:

debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [140.82.118.4] port 22.
debug1: Connection established.
debug1: identity file /home/warwick/.ssh/id_rsa type 0
debug1: identity file /home/warwick/.ssh/id_rsa-cert type -1
debug1: identity file /home/warwick/.ssh/id_dsa type -1
debug1: identity file /home/warwick/.ssh/id_dsa-cert type -1
debug1: identity file /home/warwick/.ssh/id_ecdsa type -1
debug1: identity file /home/warwick/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/warwick/.ssh/id_ed25519 type -1
debug1: identity file /home/warwick/.ssh/id_ed25519-cert type -1
debug1: identity file /home/warwick/.ssh/id_xmss type -1
debug1: identity file /home/warwick/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0p1 Ubuntu-6build1
debug1: Remote protocol version 2.0, remote software version babeld-17f81433
debug1: no match: babeld-17f81433
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/warwick/.ssh/known_hosts:3
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/warwick/.ssh/id_rsa RSA SHA256:XUyMmE8J489MaD9Ix/1xJdilSU4aH/F27hdhQubMQL4
debug1: Will attempt key: /home/warwick/.ssh/id_dsa 
debug1: Will attempt key: /home/warwick/.ssh/id_ecdsa 
debug1: Will attempt key: /home/warwick/.ssh/id_ed25519 
debug1: Will attempt key: /home/warwick/.ssh/id_xmss 
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/warwick/.ssh/id_rsa RSA SHA256:XUyMmE8J489MaD9Ix/1xJdilSU4aH/F27hdhQubMQL4
debug1: Server accepts key: /home/warwick/.ssh/id_rsa RSA SHA256:XUyMmE8J489MaD9Ix/1xJdilSU4aH/F27hdhQubMQL4
Enter passphrase for key '/home/warwick/.ssh/id_rsa': 
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([140.82.118.4]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LANG = en_ZA.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi WNortier! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3452, received 2484 bytes, in 0.5 seconds
Bytes per second: sent 6930.1, received 4986.7
debug1: Exit status 1
  1. 确保您有正在使用的密钥

我根据https://help.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-accountIdentity added: /home/warwick/.ssh/id_rsa (myemail@gmail.com)

这里有一个问题:

在终端中启动eval "$(ssh-agent -s)"并运行ssh-add -l就是返回The agent has no identities.,尽管我刚刚添加了它?

将对项目src文件所做的更改推送到github不会提示我输入密码,当我检查github设置时,我会发现密钥已被使用。所以钥匙似乎在工作

每次尝试运行构建和推送时,我都会遇到Permission denied(公钥(。我根据Vue文档上的本指南创建了一个.deploy.sh文件,并在github.io推送的行中取消注释并添加了我的用户名https://cli.vuejs.org/guide/deployment.html#github-页面

set -e
npm run build
cd dist
git init
git add -A
git commit -m "deploy"
git push -f git@github.com:wnortier/wnortier.github.io.git master
cd -

但当我用sh .deploy.sh运行它时,它会返回

DONE  Compiled successfully in 2175ms                                  15:40:48
File                                 Size               Gzipped
dist/js/chunk-vendors.c4d3d4de.js    114.27 KiB         40.31 KiB
dist/js/app.8b5fd9c9.js              6.99 KiB           2.90 KiB
dist/css/app.35dcd38a.css            0.27 KiB           0.21 KiB
Images and other types of assets omitted.
DONE  Build complete. The dist directory is ready to be deployed.
INFO  Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html
Initialized empty Git repository in /home/warwick/Projects/wnortier.github.io/dist/.git/
[master (root-commit) 74551eb] deploy
8 files changed, 14 insertions(+)
create mode 100644 css/app.35dcd38a.css
create mode 100644 favicon.ico
create mode 100644 img/logo.82b9c7a5.png
create mode 100644 index.html
create mode 100644 js/app.8b5fd9c9.js
create mode 100644 js/app.8b5fd9c9.js.map
create mode 100644 js/chunk-vendors.c4d3d4de.js
create mode 100644 js/chunk-vendors.c4d3d4de.js.map
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

git配置如下:

user.email=warwick.nortier@gmail.com
user.name=warwick
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/WNortier/wnortier.github.io.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
user.name=warwick
user.email=warwick.nortier@gmail.com

有人能帮我吗?

事实证明,我的ssh密钥一直都设置正确
我已通过运行以下命令解决了问题:sudo chown -R $USERNAME /home/<myusername>它允许我在没有[sudo]的情况下运行部署脚本。

在会话中设置GIT_SSH_COMMAND(作为您,而不是root用户(

export GIT_SSH_COMMAND='ssh -Tv'

然后运行你的脚本。

您将在问题中看到相同类型的调试日志
如果没有,则意味着脚本没有使用您的配置文件环境设置运行,这可以解释为什么手动执行时它在命令行中工作,而不是通过所述脚本。

最新更新