2016-07-15 112 views
0

這與我的previous question有關。基本上,概括地說:我ec2-import-instance生成一個沒有公共IP的實例

1)設置一個流浪漢的ubuntu 14.04盒局部

2)打包的流浪實例成package.box以下these instructions

3)轉換的package.box.vmdk文件使用this function

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我讀過的東西(但從來沒有用過/不知道它做了什麼),我試過以上兩次:一旦與原始/etc/cloud/cloud.cfg文件,並再次與/etc/cloud/cloud.cfg文件,我發現here

基本上,我最終在AWS Console中看到的是一個沒有公共IP地址的正在運行的實例。我將Elastic IP附加到實例,但由於某種原因,我無法ssh進入該IP地址 - 它表示port 22: Connection refused

我無所事事,因爲這些實例在具有安全組的默認VPC中啓動附加到它,允許從任何IP的所有端口和所有協議。順便說一下:我對所有的AWS都很陌生,並沒有真正瞭解我的方式,所以任何直接的指導將不勝感激。

原始/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文件:

users: 
- default 
disable_root: 1 
ssh_pwauth: 0 
locale_configfile: /etc/sysconfig/i18n 
mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2'] 
resize_rootfs_tmp: /dev 
ssh_deletekeys: 0 
ssh_genkeytypes: ~ 
syslog_fix_perms: ~ 
cloud_init_modules: 
- bootcmd 
- write-files 
- resizefs 
- set_hostname 
- update_hostname 
- update_etc_hosts 
- rsyslog 
- users-groups 
- ssh 
cloud_config_modules: 
- mounts 
- locale 
- set-passwords 
- timezone 
- runcmd 
cloud_final_modules: 
- scripts-per-once 
- scripts-per-boot 
- scripts-per-instance 
- scripts-user 
- ssh-authkey-fingerprints 
- keys-to-console 
- final-message 
system_info: 
    distro: rhel 
    default_user: 
    name: ec2-user 
    paths: 
    cloud_dir: /var/lib/cloud 
    templates_dir: /etc/cloud/templates 
    ssh_svcname: sshd 
EOF 
+0

你能檢查你的實例創建的子網設置嗎?你在這個截圖中看到IGW嗎? https://www.dropbox.com/s/9sn6y9o5jl7hg6h/SCSH.png?dl=0 – error2007s

+0

是的,我明白了(這是我擁有的唯一子網):http://i.imgur.com/aQqtKQZh.jpg –

+0

你用什麼命令和密鑰ssh進入實例? – error2007s

回答

1

發生這種情況,因爲當你從本地轉移的實例AWS有與之關聯沒有任何PEM關鍵由於你無法SSH的實例。

在您拍攝實例的圖像並使用關聯的密鑰重新啓動實例後,您可以將SSH連接到實例中。

相關問題