ec2-import-instance创建一个没有公共IP的实例

时间:2016-07-15 16:47:00

标签: amazon-web-services amazon-ec2 vagrant

这与我的previous question有关。基本上,总结一下:我

1)在本地设置一个流浪汉ubuntu 14.04框

2)将vagrant实例打包到these instructions

之后的package.box

3)使用this function

package.box转换为.vmdk文件

4)执行以下CLI命令:

 ec2-import-instance tmpdir/box-disk1.vmdk -f VMDK -t t2.micro -a x86_64 -b <S3 Bucket> -o $AWS_ACCESS_KEY -w $AWS_SECRET_KEY -p Linux

因为我怀疑这个问题是关于cloud-init这个我读过的东西(但从来没有使用/不知道它做了什么),我尝试了两次:一次使用原始的{{ 1}}文件,再次使用我找到的/etc/cloud/cloud.cfg文件here

基本上,我最终在AWS控制台中看到的是一个没有公共IP地址的正在运行的实例。我将弹性IP附加到实例,但出于某种原因我无法访问该IP地址 - 它说/etc/cloud/cloud.cfg

我感到茫然,因为这些实例正在默认VPC中启动,默认VPC上附有一个安全组,允许来自任何IP的所有端口和所有协议。

顺便说一下:我对所有AWS都很陌生,并且完全不知道我在控制台周围的方式,所以任何直接指导都会非常感激。

原始port 22: Connection refused档案:

/etc/cloud/cloud.cfg

第二次尝试# The top level settings are used as module # and system configuration. # A set of users which may be applied and/or used by various modules # when a 'default' entry is found it will reference the 'default_user' # from the distro configuration specified below users: - default # If this is set, 'root' will not be able to ssh in and they # will get a message to login instead as the above $user (ubuntu) disable_root: true # This will cause the set+update hostname module to not operate (if true) preserve_hostname: false # Example datasource config # datasource: # Ec2: # metadata_urls: [ 'blah.com' ] # timeout: 5 # (defaults to 50 seconds) # max_wait: 10 # (defaults to 120 seconds) # The modules that run in the 'init' stage cloud_init_modules: - migrator - seed_random - bootcmd - write-files - growpart - resizefs - set_hostname - update_hostname - update_etc_hosts - ca-certs - rsyslog - users-groups - ssh # The modules that run in the 'config' stage cloud_config_modules: # Emit the cloud config ready event # this can be used by upstart jobs for 'start on cloud-config'. - emit_upstart - disk_setup - mounts - ssh-import-id - locale - set-passwords - grub-dpkg - apt-pipelining - apt-configure - package-update-upgrade-install - landscape - timezone - puppet - chef - salt-minion - mcollective - disable-ec2-metadata - runcmd - byobu # The modules that run in the 'final' stage cloud_final_modules: - rightscale_userdata - scripts-vendor - scripts-per-once - scripts-per-boot - scripts-per-instance - scripts-user - ssh-authkey-fingerprints - keys-to-console - phone-home - final-message - power-state-change # System and/or distro specific settings # (not accessible to handlers/transforms) system_info: # This will affect which distro class gets used distro: ubuntu # Default user name + that default users groups (if added/used) default_user: name: ubuntu lock_passwd: True gecos: Ubuntu groups: [adm, audio, cdrom, dialout, dip, floppy, netdev, plugdev, sudo, video] sudo: ["ALL=(ALL) NOPASSWD:ALL"] shell: /bin/bash # Other config here will be given to the distro class and/or path classes paths: cloud_dir: /var/lib/cloud/ templates_dir: /etc/cloud/templates/ upstart_dir: /etc/init/ package_mirrors: - arches: [i386, amd64] failsafe: primary: http://archive.ubuntu.com/ubuntu security: http://security.ubuntu.com/ubuntu search: primary: - http://%(ec2_region)s.ec2.archive.ubuntu.com/ubuntu/ - http://%(availability_zone)s.clouds.archive.ubuntu.com/ubuntu/ - http://%(region)s.clouds.archive.ubuntu.com/ubuntu/ security: [] - arches: [armhf, armel, default] failsafe: primary: http://ports.ubuntu.com/ubuntu-ports security: http://ports.ubuntu.com/ubuntu-ports ssh_svcname: ssh 档案:

/etc/cloud/cloud.cfg

1 个答案:

答案 0 :(得分:1)

这种情况正在发生,因为当您从本地将实例传输到AWS时,没有任何与该实例关联的PEM密钥,因为您无法通过SSH进行。

获取实例的图像并使用关联的密钥再次启动实例后,您可以通过SSH连接到实例。