VirtualBox 安装 Amazon linux2

本贴最后更新于 1380 天前,其中的信息可能已经时移世改

VirtualBox 安装 Amazon linux2

环境准备

1.下载镜像

https://cdn.amazonlinux.com/os-images/2.0.20201111.0/virtualbox/

2.下载引导文件

https://cdn.amazonlinux.com/os-images/2.0.20201111.0/Seed.iso

VirtualBox 版本 6.1,安装步骤不在本文范围

创建虚拟机

image.png

这边输入 linux2,VirtualBox 会帮你自动识别类型和版本,点击下一步,选择分配的内存,点击下一步,选择使用已有的虚拟硬盘文件,如下图所示:

image.png

选择在官网下载镜像 vdi 文件所在的位置,点击创建

使用 SSH 连接

安装之后,发现不知道 root 密码,然后查阅相关资料,发现需要根据自身需求,生成一个 seed.iso 的引导镜像挂载到服务器上

 For on-prem images, we recommend using the NoCloud data source:
 
 https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html
 
 On-prem images also support the AltCloud, ConfigDrive, and OVF
 cloud-init data sources. More information on datasources at:
 
 https://cloudinit.readthedocs.io/en/latest/topics/datasources.html#datasource-documentation
 
 
 The seed image for NoCloud can be generated by writing two YAML files,
 meta-data and user-data, and making them part of an ISO image. This ISO
 needs to be attached to the virtual machine on first boot. More information on
 generating the seed ISO is at:
 https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html
 
 
 -----BEGIN meta-data SAMPLE------
 local-hostname: amazonlinux.onprem
 
 # eth0 is the default network interface enabled in the image. You can
 # configure static network settings with an entry like below.
 
 network-interfaces: |
   iface eth0 inet static
   address 192.168.1.10
   network 192.168.1.0
   netmask 255.255.255.0
   broadcast 192.168.1.255
   gateway 192.168.1.254
 -----END meta-data SAMPLE------
 
 -----BEGIN user-data SAMPLE------
 #cloud-config
 # vim:syntax=yaml
 users:
 # A user by the name ec2-user is created in the image by default.
 - default
 # The following entry creates user1 and assigns a plain text password.
 # Please note Security best practises recommend not using plain text password.
   - name: user1
     gecos: test user1 with plain passwd configured and sudo nopasswd enabled
     groups: sudo
     sudo: ['ALL=(ALL) NOPASSWD:ALL']
     plain_text_passwd: < plain text password here >
     lock_passwd: false
 # The following entry creates user2 and attaches a hashed password to the user.
 # Hashed passwords can be generated with the following command on Amazon Linux 2:
 # python -c 'import crypt,getpass; print crypt.crypt(getpass.getpass())'
   - name: user2
     gecos: test user2 with hashed passwd configured
     passwd: < hashed password here >
     lock_passwd: false
 # The following entry creates user3, disables password-based login and enables an SSH public key.
   - name: user3
     gecos: test user3 with SSH key configured
     ssh-authorized-keys:
       - ssh-public-key-information
     lock_passwd: true
 chpasswd:
   list: |
     ec2-user:<plain text password here>
 # In the above line, do not add any spaces after 'ec2-user:'.
 
 # NOTE: Cloud-init applies network settings on every boot by default. To retain network settings from first
 boot, uncomment the following 鈥榳rite_files鈥� section:
 #write_files:
 #  - path: /etc/cloud/cloud.cfg.d/80_disable_network_after_firstboot.cfg
 #    content: |
 #       # Disable network configuration after first boot
 #       network:
            config: disabled
 -----END user-data SAMPLE------
 
 
 To build seed.iso from user-data and meta-data files:
 
 $ genisoimage  -output seed.iso -volid cidata -joliet -rock user-data meta-data

为了尽快进入系统·本尊·,直接使用官方的 seed.iso,默认带 sudo 的用户是 user1,密码是 amazon

重新启动系统,使用账号密码成功进入系统

修改/etc/ssh/sshd_conf 文件,开放 SSH 账号密码登录

基本命令和 CentOS 大同小异,没有多少出入。

最后的效果图如下:

image.png

  • Linux

    Linux 是一套免费使用和自由传播的类 Unix 操作系统,是一个基于 POSIX 和 Unix 的多用户、多任务、支持多线程和多 CPU 的操作系统。它能运行主要的 Unix 工具软件、应用程序和网络协议,并支持 32 位和 64 位硬件。Linux 继承了 Unix 以网络为核心的设计思想,是一个性能稳定的多用户网络操作系统。

    939 引用 • 940 回帖

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...