我正在调整Ubuntu的云版本默认设置在哪里是拒绝根login。
试图连接到这样的机器产量:
maxim@maxim-desktop:~/workspace/integration/deployengine$ ssh [email protected] The authenticity of host 'ec2-204-236-252-95.compute-1.amazonaws.com (204.236.252.95)' can't be established. RSA key fingerprint is 3f:96:f4:b3:b9:4b:4f:21:5f:00:38:2a:bb:41:19:1a. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'ec2-204-236-252-95.compute-1.amazonaws.com' (RSA) to the list of known hosts. Please login as the ubuntu user rather than root user. Connection to ec2-204-236-252-95.compute-1.amazonaws.com closed.
我想知道什么configuration文件通过SSHconfiguration根阻塞,以及如何更改打印的消息?
老问题,但没有人真的回答你,我也有同样的问题:这个configuration从哪里来?
它来源于cloudinit ,正好在/usr/lib/python2.7/dist-packages/cloudinit/config中的cc_ssh.py
这又是直接依赖于文件/etc/cloud/cloud.cfg 。 你find一行disable_root: true 。
您应该可以通过调整您的用户数据并添加行disable_root: false来覆盖它。 您的云提供商应该使用户数据可configuration。
假设你的sshdconfiguration有PermitRootLogin yes 。
sudo grep "login as the ubuntu user" /root/.??*
然而,迈克·斯科特提供的链接是我强烈build议你仔细阅读并注意。
ROOT SSH
最后,如果您希望绕过Ubuntu安全标准,并恢复到以root身份允许ssh和rsync的旧做法,则该命令将为官方Ubuntu映像的新实例打开它:
ssh -i KEYPAIR.pem ubuntu@HOSTNAME 'sudo cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'这不是build议的,但它可能是一种让现有的EC2自动化代码继续工作的方法,直到你可以升级到上面描述的sudo实践。
我保持根SSHlogin被禁用,因为任何启用了SSH的面向公共服务的服务器将会在犯罪僵尸networking的根login尝试中连续白天和晚上遭受攻击。
文件在其他地方警告
启用Root帐户是很less需要的。 几乎所有你需要做的Ubuntu系统的pipe理员可以通过sudo或gksudo完成。 如果你真的需要持久的Rootlogin,最好的select是使用下面的命令来模拟Rootloginshell。
sudo -i
答案在这里: http : //alestic.com/2009/04/ubuntu-ec2-sudo-ssh-rsync
将ubuntu账户中的authorized_keys文件复制到root帐户。 密码login被禁用,所以你必须有一个有效的SSH密钥login到任何帐户。
检查/ etc / ssh / sshd_config,选项叫做“Permit root login”
PermitRootLogin Specifies whether root can log in using ssh(1). The argument must be “yes”, “without-password”, “forced-commands-only”, or “no”.
其中一个更有用的设置是“没有-password”,让我们login到根,但只有当您使用公钥authentication。 man sshd_config了解更多信息:)