大网数据广告活动
服务器运维问答

Prevent SSH access to instances launched from AWS AMI

· 52CE 我爱测

We are trying to make a secured AMI for distribution to one of our customers (running Linux/CoreOS). Once our customer deploys our AMI, it is important that they cannot obtain shell access (e.g cannot SSH in). On the surface, thi…

问题原文

原帖链接 · BadApple · CC BY-SA 3.0

We are trying to make a secured AMI for distribution to one of our customers (running Linux/CoreOS). Once our customer deploys our AMI, it is important that they cannot obtain shell access (e.g cannot SSH in).

On the surface, this seems like a very simple problem to solve: just make sure that only our keys are in the authorized_keys files. However, when our customer deploys our AMI, they are forced to provide their own key pair, and then the associated public key is inserted into the authorized_keys file on the box, enabling them to SSH into the box.

I know that Amazon makes the public key accessible (and user metadata) to the Host OS via HTTP on 169.254.169.254 (info here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html). Some sleuthing around the Internet and the CoreOS filesystem suggests that the /usr/bin/coreos-metadata actually accesses this IP, presumably for the keypair, but I can't figure out what is actually kicking off that executable or how to disable it. I even thought about removing executable privileges or remove it entirely, but that part of the filesystem is read-only on CoreOS (even to root).

Obviously the above behavior trumps whatever security measures we put in place. Is there anything we can do to prevent this from happening?

已采纳解答

原帖链接 · Skaperen · CC BY-SA 3.0

cloud-init is doing this. Disable sshd from running (part of your AMI build), then have script code run that puts your keys in place under the login user (a different one is suggested), start up ssh. I also suggest a different port number as an easy way to confirm you have things working right.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。