繁体   English   中英

Gitlab 个人服务器:权限被拒绝(公钥)

[英]Gitlab personal server: Permission denied (publickey)

我已经安装了 Gitlab 服务器(15.1)并尝试为我的用户完成配置。

我可以将 ssh 连接到服务器以进行管理。我的用户。 我为此使用 rsa 密钥对。 我连接到 22002 端口,一切正常。

现在我想按照 Gitlab 指令创建一个项目,一对新的密钥并使用这个密钥对将我的存储库连接到 Gitlab。 I have created keys (ed25519), copy the public part into the Gitlab web server and just try the command ssh -T myuser@gitlab.mydomain.com

我得到以下结果:

权限被拒绝(公钥)

我已经搜索了几个小时,但没有找到我做错了什么。

如果我运行ssh -Tvvv myuser@gitlab.mydomain.com我得到以下结果:

OpenSSH_9.0p1 Debian-1+b1, OpenSSL 3.0.4 21 Jun 2022
debug1: Reading configuration data /home/tasseb/.ssh/config
debug1: /home/tasseb/.ssh/config line 19: Applying options for gitlab-kb
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 *
debug1: Connecting to gitlab.mydomain.com [160.53.247.6] port 22002.
debug1: Connection established.
debug1: identity file /home/tasseb/.ssh/id_ed25519-gitlab type 3
debug1: identity file /home/tasseb/.ssh/id_ed25519-gitlab-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.0p1 Debian-1+b1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.4p1 Debian-5+deb11u1
debug1: compat_banner: match: OpenSSH_8.4p1 Debian-5+deb11u1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to gitlab.mydomain.com:22002 as 'sbe'
debug1: load_hostkeys: fopen /home/tasseb/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
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: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:ofs8tNkzOxuU5AwC2VYbFGPXfERPKXGOFrTatb8hV78
tlab.mydomain.com]:22002
debug1: load_hostkeys: fopen /home/tasseb/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '[gitlab.mydomain.com]:22002' is known and matches the ED25519 host key.
debug1: Found key in /home/tasseb/.ssh/known_hosts:4
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: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent contains no identities
debug1: Will attempt key: /home/tasseb/.ssh/id_ed25519-gitlab ED25519 SHA256:7BtjWt7Ysd40SJ1xX1sBlZb7PJqUW5K2NhxDBvtIgfY explicit 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/tasseb/.ssh/id_ed25519-gitlab ED25519 SHA256:7BtjWt7Ysd40SJ1xX1sBlZb7PJqUW5K2NhxDBvtIgfY explicit
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
sbe@gitlab.mydomain.com: Permission denied (publickey).

谢谢你的帮助。

我确信这是我省略的一些简单的事情。 所以今天早上我只是继续在本地设置我的 git 项目,并使用我的用户和密码进行了第一次推送。 那运作良好。 然后,我编辑 my.ssh/config 文件,按照@VonC 的建议将我的用户名更改为“git”。 重新运行测试,它要求输入密钥的密码,一切正常。 我以为我可以在进行第一次推送或在本地设置原点之前设置 ssh,但似乎不行。

再次感谢您的宝贵意见。

将 SSH URL 与 GitLab 本地服务器一起使用应始终涉及技术帐户 Z76F11,而不是“33my3492”BD61E593
请参阅“ 验证您是否可以连接

ssh -Tvvv git@gitlab.mydomain.com

GitLab 将通过注册到 GitLab 用户帐户 SSH 设置页面的公钥对您进行身份验证。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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