用 ssh-keygen 命令创建了密钥,并把公钥复制到了 gitlab 上。接下来要如何配置私钥?
1
ahaooahaz 307 天前
ssh-keygen 同时生成了公钥和私钥,私钥只留在机器上,上传公钥之后直接用就可以了
|
2
gegeligegeligo OP @ahaooahaz #1 但是 push 的时候提示 Permission denied (publickey)。不知道是什么原因,这个要怎么排查问题😭
|
3
once1mo 307 天前
... ssh-keygen 生成的时候既有公钥也有私钥。
|
4
Daniate 307 天前 1
gitlab 太重了,我选 gitea
|
5
IvanLi127 307 天前
ssh -T -v git@your-gitlab.com
|
6
IvanLi127 307 天前
|
7
haichao0808 307 天前
@gegeligegeligo 是不是贴错 key 文件了,是那个 id_rsa.pub 文件的内容。要不就检查下仓库是否开了 push 权限或者用户权限不对
|
8
dontLookAvatar 307 天前 1
开 ssh 让我上去看看
|
9
gegeligegeligo OP @IvanLi127 #6 这个 git@your-gitlab.com 要怎么改,比如我的服务器地址是 192.168.2.2 ,端口是 30001
|
11
storyxc 307 天前
编辑~/.ssh/config
# gitlab Host gitlab HostName your-gitlab.com PreferredAuthentications publickey IdentityFile ~/.ssh/your-gitlab-private-key |
12
IvanLi127 307 天前
@gegeligegeligo #9 ssh -T -v -p 30001 [email protected]
|
13
gegeligegeligo OP @storyxc #11 还是不行,Permission denied (publickey).
|
14
gegeligegeligo OP @IvanLi127 #12 输出是这样的:
$ ssh -T -v -p 30001 [email protected] OpenSSH_9.3p1, OpenSSL 3.1.1 30 May 2023 debug1: Reading configuration data /c/Users/99192/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to 192.168.5.235 [192.168.5.235] port 30001. debug1: Connection established. debug1: identity file /c/Users/99192/.ssh/id_rsa type -1 debug1: identity file /c/Users/99192/.ssh/id_rsa-cert type -1 debug1: identity file /c/Users/99192/.ssh/id_ecdsa type -1 debug1: identity file /c/Users/99192/.ssh/id_ecdsa-cert type -1 debug1: identity file /c/Users/99192/.ssh/id_ecdsa_sk type -1 debug1: identity file /c/Users/99192/.ssh/id_ecdsa_sk-cert type -1 debug1: identity file /c/Users/99192/.ssh/id_ed25519 type 3 debug1: identity file /c/Users/99192/.ssh/id_ed25519-cert type -1 debug1: identity file /c/Users/99192/.ssh/id_ed25519_sk type -1 debug1: identity file /c/Users/99192/.ssh/id_ed25519_sk-cert type -1 debug1: identity file /c/Users/99192/.ssh/id_xmss type -1 debug1: identity file /c/Users/99192/.ssh/id_xmss-cert type -1 debug1: identity file /c/Users/99192/.ssh/id_dsa type -1 debug1: identity file /c/Users/99192/.ssh/id_dsa-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_9.3 debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.2 debug1: compat_banner: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.2 pat OpenSSH* compat 0x04000000 debug1: Authenticating to 192.168.5.235:30001 as 'test' debug1: load_hostkeys: fopen /c/Users/99192/.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: [email protected] MAC: <implicit> compression: none debug1: kex: client->server cipher: [email protected] 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:hqhfESj5oWFkoqjXnnLjxSYqlDSapKkeNRyW5saL0IM debug1: load_hostkeys: fopen /c/Users/99192/.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 '[192.168.5.235]:30001' is known and matches the ED25519 host key. debug1: Found key in /c/Users/99192/.ssh/known_hosts:5 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: agent returned 1 keys debug1: Will attempt key: /c/Users/99192/.ssh/id_ed25519 ED25519 SHA256:LKGgr4p5eDgiBWTvVNCo7zub/B8+Zlt3Xz6Epy921LI agent debug1: Will attempt key: /c/Users/99192/.ssh/id_rsa debug1: Will attempt key: /c/Users/99192/.ssh/id_ecdsa debug1: Will attempt key: /c/Users/99192/.ssh/id_ecdsa_sk debug1: Will attempt key: /c/Users/99192/.ssh/id_ed25519_sk debug1: Will attempt key: /c/Users/99192/.ssh/id_xmss debug1: Will attempt key: /c/Users/99192/.ssh/id_dsa debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering public key: /c/Users/99192/.ssh/id_ed25519 ED25519 SHA256:LKGgr4p5eDgiBWTvVNCo7zub/B8+Zlt3Xz6Epy921LI agent debug1: Authentications that can continue: publickey debug1: Trying private key: /c/Users/99192/.ssh/id_rsa debug1: Trying private key: /c/Users/99192/.ssh/id_ecdsa debug1: Trying private key: /c/Users/99192/.ssh/id_ecdsa_sk debug1: Trying private key: /c/Users/99192/.ssh/id_ed25519_sk debug1: Trying private key: /c/Users/99192/.ssh/id_xmss debug1: Trying private key: /c/Users/99192/.ssh/id_dsa debug1: No more authentication methods to try. [email protected]: Permission denied (publickey). |
15
gegeligegeligo OP 不知道为什么提示了 Host '[192.168.5.235]:30001' is known and matches the ED25519 host key ,但是还是 Permission denied
|
16
gegeligegeligo OP 😭😭😭help me 这是为什么
|
17
ray1980 306 天前
~/.ssh/config 文件的配置里加 User git
|
18
jim9606 306 天前
ssh 用户名固定是 git ,不会是别的用户名,通常不能省略。
ssh -T -v -p 30001 [email protected] 看上去私钥文件没放错地方 /c/Users/99192/.ssh/id_ed25519 ,你要上传的是 /c/Users/99192/.ssh/id_ed25519.pub |
19
yuningWang8 283 天前
之前也遇到了同样的问题。不知道楼主解决了没有。你是不是部署的时候,修改了 gitlab 的 22 端口?如果是的话,要么改回 22 端口。要么修改一下项目的 remote 地址,指定端口号,例如:ssh://git@xxxxxx:2222/abc/def 2222 是你修改的端口号。
|