无法使用 SSH 连接Azure Linux 虚拟机

网友投稿 344 2022-09-28

无法使用 SSH 连接Azure Linux 虚拟机

​本文提供了因为 /var/empty/sshd 文件不在根目录且不可进行组或全局可写导致SSH 连接失败问题的解决方案。

​问题现象​

​​无法使用安全外壳 (SSH) 连接来连接 Linux 虚拟机 (VM)。发生此问题时,您可能会收到以下有关 /var/empty/sshd 文件的错误消息,具体取决于 Linux 发行版。​

​SuSE:​

/var/empty must be owned by root and not group or world-writable.

startproc: exit status of parent of /usr/sbin/sshd: 255

​Failed​

​Centos:​

Starting sshd: /var/empty/sshd must be owned by root and not group or world-writable.

​[FAILED]​

原因

如果 /var/empty/sshd 文件不归根目录所有,并且不可进行组写入或全局写入,则可能会出现此问题。

解决方案

若要在无法访问 SSH 时更改 Linux 文件的权限,在 Azure 门户 中打开虚拟机的"属性"窗口,检查代理状态。

如果代理已启用,请按照以下步骤更改权限:

将以下脚本复制到本地计算机,然后将该文件重命名为 update_perms.sh。

#!/bin/bash

#Script to change permissions on a file

###################################################

param=$1

chmod 755 /var/empty/sshd;chown root:root /var/empty/sshd;service sshd restart

转到 Azure 门户,找到 VM 设置,然后选择扩展 >,为Linux 创建 > 添加自定义 > 脚本。

在 "脚本文件"中,上载 update_perms.sh 文件,然后单击"确定 "。

将脚本推送到 VM 后 ,STATUS 值应为 Success。

the update_perms.sh sample script changes the permissions on the /var/empty/sshd file from 777 to 755 and sets the owner and group to root:root. 等待脚本运行。 这可能需要几分钟。 Linux 代理接收请求,然后提交到正确的扩展。 如果可以使用 SSH 连接连接到 VM,并且希望查看运行 update_params.sh 脚本时发生的情况,请检查目录中的 extension.log /var/log/azure/Microsoft.OSTCExtensions.CustomScriptForLinux/ 文件。

。​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:SpringBoot利用validation实现优雅的校验参数
下一篇:无法通过网络连接到 Azure Linux 虚拟机解决方案
相关文章

 发表评论

暂时没有评论,来抢沙发吧~