4

OpenStack允许root用户使用ssh-key登录 - 夜雨秋灯录

 2 years ago
source link: https://privaterookie.github.io/posts/2019-07-03-OpenStack%E5%85%81%E8%AE%B8root%E7%94%A8%E6%88%B7%E4%BD%BF%E7%94%A8ssh-key%E7%99%BB%E5%BD%95.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

OpenStack允许 root 用户使用 ssh key 登录

参考: Enable Root Login Over SSH With Cloud-Init on OpenStack


默认情况下如果在创建虚拟机时将 ssh 密钥注入后尝试使用 root 用户登录会提示:

Please login as the user "centos" rather than the user "root".

此时需要移除 /root/.ssh/authorized_keys 第一行的如下内容:

no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"centos\" rather than the user \"root\".';echo;sleep 10"

并检查 /etc/ssh/sshd_config 中的 PermitRootLogin 配置项,确保其设置如下:

PermitRootLogin without-password

随后重启 sshd 服务。


如果不想在每次创建成功后手动修改,需要修改镜像中的 cloud-init 配置项, 修改 /etc/cloud/cloud.cfg 如下配置项:

disable_root: false
# 或者
disable_root: 0

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK