使用 SSH 登录设备时出现“拒绝访问 (Access Denied)”错误
search cancel

使用 SSH 登录设备时出现“拒绝访问 (Access Denied)”错误

book

Article ID: 341120

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

通过 SSH 登录 vCenter Server 失败且出现“拒绝访问 (Access Denied)”错误时,请将用户的默认 shell 设置为 bash。

Symptoms:
免责声明:本文为 "Access Denied" error when using SSH to login to the appliance (2146205) 的翻译版本。尽管我们会不断努力为本文提供最佳翻译版本,但本地化的内容可能会过时。有关最新内容,请参见英文版本。

  • 使用 SSH 登录 vCenter Server Appliance 失败且出现以下错误:

    拒绝访问 (Access Denied)

    注意:有关其他症状和日志条目,请参见“Additional Information” 部分。


Environment

VMware vCenter Server Appliance 6.0.x
VMware vCenter Server Appliance 5.5.x

Cause

当用户的默认 shell 设为无效 shell 时,会出现此问题。

Resolution

要确认出现了此问题,请执行以下操作:
  1. 在 GRUB 引导加载程序上,按 p 键。
  2. 系统出现提示时,输入 root 凭据。
  3. 选择 VMware vCenter Server Appliance 并按 e 键。
  4. 选择以 kernel 开头的行并按 e 键。
  5. init=/bin/bash 添加到行尾并按 Enter 键。此行应当以 <nousb audit=1</span> 开头。
  6. 按 b 键。
  7. 运行以下命令以查看用户的 shell 设置:

    cat /etc/passwd

    例如:

    ...
    polkituser:x:103:104:PolicyKit:/var/run/PolicyKit:/bin/false
    postfix:x:51:51:Postfix Daemon:/var/spool/postfix:/bin/false
    root:x:0:0:root:/root:/bin/appliancesh

    ...

  8. root 条目应为 root:x:0:0:root:/root:/bin/appliancesh。如果此条目不包含 /root:/bin/appliancesh,请检查 /root/.bash_history 文件以查看是否使用以下命令设置了无效 shell:

    less /root/.bash_history

    例如:

    #1468577177
    chsh -s "/bin/bosh" root


    注意:在上例中,root 用户的 shell 被错误设置为 "/bin/bosh"。上述行是此事件的时间戳(采用 epoch 格式)。

要解决此问题,请将用户的默认 shell 设置为 bash:
  1. 运行以下命令将默认 Shell 设置为 BASH:

    chsh -s /bin/bash root

  2. 通过运行以下命令重新启动设备:

    reboot


Additional Information

您还会遇到以下症状:
  • 将返回到登录屏幕。
  • 使用相同的凭据成功登录到 VAMI (https://VC_IP:5480)。
  • 使用虚拟机控制台登录失败且出现以下错误:

    无效 Shell (Invalid Shell)

    注意:此处仅简要显示该错误。

  • /var/log/messages.log 文件中,您会看到类似以下内容的条目:

    2016-07-15T10:49:51.021176+00:00 vc sshd[23037]: User root not allowed because shell /bin/bosh does not exist
"Access Denied" error when using SSH to login to the appliance