AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 813519
Accepted
Manuth Chek
Manuth Chek
Asked: 2016-11-07 21:02:10 +0800 CST2016-11-07 21:02:10 +0800 CST 2016-11-07 21:02:10 +0800 CST

SSH 显然没有读取 ~/.ssh 中的密钥

  • 772

这是 Ubuntu 16.04 客户端的输出:

OpenSSH_7.2p2 Ubuntu-4, OpenSSL 1.0.2g-fips  1 Mar 2016
debug1: Reading configuration data /home/manuth/.ssh/config
debug1: /home/manuth/.ssh/config line 1: Applying options for r2d2.manuth.life
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to r2d2.manuth.life [103.12.163.90] port 900.
debug1: Connection established.
debug1: identity file /home/manuth/.ssh/dqar-rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/manuth/.ssh/dqar-rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4
ssh_exchange_identification: Connection closed by remote host

的路径和权限/home/manuth/.ssh/dqar-rsa也是正确的:

$ ls -l /home/manuth/.ssh/dqar-rsa*
-rw------- 1 manuth manuth 3243 Nov  7 11:27 /home/manuth/.ssh/dqar-rsa
-rw-r--r-- 1 manuth manuth  740 Nov  7 11:27 /home/manuth/.ssh/dqar-rsa.pub

此主机的条目~/.ssh/config是:

host r2d2.manuth.life
 IdentityFile ~/.ssh/dqar-rsa
 Port 900
 IdentitiesOnly yes
 ForwardX11 yes

如果我尝试评论该IdentityFile行,它甚至不会读取任何id_*内容~/.ssh:

OpenSSH_7.2p2 Ubuntu-4, OpenSSL 1.0.2g-fips  1 Mar 2016
debug1: Reading configuration data /home/manuth/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to r2d2.manuth.life [103.12.163.90] port 900.
debug1: Connection established.
debug1: identity file /home/manuth/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/manuth/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/manuth/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/manuth/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/manuth/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/manuth/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/manuth/.ssh/id_ed25519 type 4
debug1: key_load_public: No such file or directory
debug1: identity file /home/manuth/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4
ssh_exchange_identification: Connection closed by remote host

这似乎是今天突然出现的。

编辑:里面的内容~/.ssh:

$ ls -la
insgesamt 36
drwx------  2 manuth manuth 4096 Nov  7 16:28 .
drwxr-xr-x 53 manuth manuth 4096 Nov  7 13:31 ..
-rw-r--r--  1 manuth manuth  805 Nov  7 12:10 authorized_keys
-rw-r--r--  1 manuth manuth  543 Nov  7 13:47 config
-rw-------  1 manuth manuth  411 Nov  7 12:10 dqar-ed25519
-rw-r--r--  1 manuth manuth   96 Nov  7 12:10 dqar-ed25519.pub
-rw-------  1 manuth manuth 3243 Nov  7 12:10 dqar-rsa
-rw-r--r--  1 manuth manuth  740 Nov  7 12:10 dqar-rsa.pub
-rw-r--r--  1 manuth manuth 1990 Nov  7 15:14 known_hosts

编辑 2:啊哈哈,控制台输出是这样的几行:

Nov 7 13:51:32 dqar sshd [11316]: fatal: Missing privilege separation directory: /var/empty

有问题的服务器是 FreeBSD 10.3。

ssh
  • 2 2 个回答
  • 30346 Views

2 个回答

  • Voted
  1. Best Answer
    Jakuje
    2016-11-08T01:19:16+08:002016-11-08T01:19:16+08:00
    debug1: identity file /home/manuth/.ssh/dqar-rsa type 1
    

    说它成功读取了文件。失败在其他地方。

    ssh_exchange_identification: Connection closed by remote host
    

    这是真正的问题。由于某种原因,您无法建立与远程主机的 SSH 连接。您可能被列入黑名单,/etc/hosts.deny或者服务器由于其他原因(缺少目录、磁盘故障、磁盘满等)而无法接受连接并启动 SSH 协议。来自服务器的日志会告诉你更多信息。

    Nov 7 13:51:32 dqar sshd [11316]: fatal: Missing privilege separation directory: /var/empty
    

    解释得差不多了。如果由于某些原因将其删除,则需要创建此目录并设置适当的权限(除 root 以外的任何其他用户均不可写)。

    • 15
  2. Manuth Chek
    2016-11-08T02:37:32+08:002016-11-08T02:37:32+08:00

    所以原因是,不知何故,没有/var/empty. 我从这个论坛帖子中创建了它(我知道它适用于 Juniper,但它也适用于这个 FreeBSD): http ://forums.juniper.net/t5/Ethernet-Switching/Missing-privilege-separation-directory-var -空/td-p/173832

    • 5

相关问题

  • 如何最好地设置 ssh 隧道以访问远程网络 (Linux)

  • SSH 和重定向

  • 通过 SSH 会话使用 NET USER 命令拒绝访问

  • SSH 服务器零日漏洞利用 - 保护自己的建议

  • ubuntu apt-get upgrade - 如何在 shell 中单击确定?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve