【问题标题】:Authorizing to my git server with `.ssh/authorized_keys` does not work使用 .ssh/authorized_keys 授权我的 git 服务器不起作用
【发布时间】:2022-12-17 21:25:55
【问题描述】:

我用 debian bullseye 在我的 NAS 上设置了一个 git server 2.30.2。

用户是git,主目录为/media/nas/programming/git_repos/,外壳为/bin/bash

主目录及其所有子目录/文件都归git:git 所有。

主目录具有770权限,主目录内的目录.ssh具有700权限。

我使用命令ssh-keygen -t ed25519 -C mymail@gmail.com(或第二次尝试ssh-keygen -t rsa -C mymail@gmail.com)创建私钥/公钥。

在 Windows PC 上,公钥变为 /media/nas/programming/git_repos/.ssh/authorized_keysgit:git 所有权,400 个权限),私钥变为 c:/Users/<username>/.ssh/id_ed25519(或第二次尝试 c:/Users/<username>/.ssh/id_rsa)。

/etc/ssh/sshd_config我有一条线AllowUsers root git ...

现在,使用 Git GUI,我正在尝试使用 url url = git@10.0.0.2:my_project 连接到远程(比如说获取)。

最初它要求密码解密id_ed25519(或第二次尝试id_rsa)。

然后它询问git@10.0.0.2 的密码,这意味着 Git 服务器根本不计算 .ssh/authorized_keys

我在这里做错了什么?

更新ssh -Tv git@10.0.0.2就不多说了:

 ....
 debug1: Authentications that can continue: publickey,password
 debug1: Next authentication method: publickey
 debug1: Trying private key: C:\\Users\\chameleon/.ssh/id_rsa
 debug1: Trying private key: C:\\Users\\chameleon/.ssh/id_dsa
 debug1: Trying private key: C:\\Users\\chameleon/.ssh/id_ecdsa
 debug1: Trying private key: C:\\Users\\chameleon/.ssh/id_ed25519
 debug1: read_passphrase: can't open /dev/tty: No such file or directory
 Enter passphrase for key 'C:\Users\chameleon/.ssh/id_ed25519':     <---- Here I give the password
 debug1: Authentications that can continue: publickey,password
 debug1: Trying private key: C:\\Users\\chameleon/.ssh/id_xmss
 debug1: Next authentication method: password
 debug1: read_passphrase: can't open /dev/tty: No such file or directory
 git@10.0.0.2's password:    <---- Here I give the password. After that, connection established.

【问题讨论】:

  • 嗯....我又想了想:StackOverflow适合这个问题吗?
  • ssh -Tv git@10.0.0.2
  • unix.stackexchange.com 或 superuser.com 可能更合适。
  • @chepner 谢谢。人们已经回答了。删帖合适吗?

标签: git ssh


【解决方案1】:

确保在远程端 (NAS ~git) 有 right permission:如果“其他人”可写任何东西,SSH 将不会考虑 authorized_keys 文件。

然后测试您与ssh -Tv git@10.0.0.2 的连接,并确认您的c:/Users/&lt;username&gt;/.ssh/id_ed25519 已被考虑和提议。
如果是,请考虑在您的 NAS 上启动 sshd in debug mode 以查看在执行 ssh -Tv 测试命令期间是否弹出任何错误消息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-03
    • 2018-08-07
    • 2016-06-23
    • 2020-11-20
    • 2022-01-01
    • 2011-02-02
    • 2023-03-10
    • 1970-01-01
    相关资源
    最近更新 更多