Post

Configuring The Amazon Linux 2023 Image For VMware

Guide: Configuring the Amazon Linux 2023 Image

Source: NoCloud (seed.iso) cloud-init configuration for Amazon Linux 2023 on KVM and VMware - Amazon Linux 2023

1. Requirements

Before you begin, make sure you have the following tools:

  • OVA file for VMware: Download the latest version.
  • A Linux machine (Ubuntu or any other distribution).
  • VS Code for creating files without a .txt extension.

2. Importing the OVA into vSphere

  1. Go to the desired OU in vSphere.
  2. Right-click and select “Deploy OVF Template”.
  3. Upload the OVA file downloaded in step 1.
  4. Follow the installation wizard and adjust the settings as needed. Important: Do not start the VM after completing the setup!

3. Creating Configuration Files

  1. Open VS Code and create two files:
    • user-data
    • meta-data
  2. Paste the following content into user-data:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#cloud-config
# This file configures a user and sets up SSH settings.
users:
  - name: myusername  # Change 'myusername' to your desired username (e.g., 'root' or 'admin')
    sudo: ALL=(ALL) NOPASSWD:ALL  # Grants the user sudo privileges without a password
    groups: sudo
    shell: /bin/bash
    lock_passwd: false  # Ensures the password is not locked

# Optional: Add an SSH key for key-based login (instead of a password)
# Uncomment and replace the example SSH key with your own if you want to use it.
#   ssh_authorized_keys: 
#     - ssh-rsa AAAAB3...jouw-ssh-key...rest-van-key 
# Replace 'myusername' and 'mypassword' with your desired login credentials

chpasswd:
  list: |
    myusername:mypassword
  expire: false  # Password does not expire automatically

# Enable password authentication and root login
ssh_pwauth: true  # Allow logging in with a password
disable_root: false  # Ensure root can log in

# Configure SSH settings to allow password login and root access
write_files:
  - path: /etc/ssh/sshd_config
    content: |
      Port 22  # Change this if you want to use a different SSH port
      PermitRootLogin yes  # Allow logging in as root
      PasswordAuthentication yes  # Enable password login
      ChallengeResponseAuthentication no
      UsePAM yes
    append: true  # Ensures the settings are added instead of overwritten

# Execute commands after the server is set up
runcmd:
  - systemctl restart sshd  # Restart SSH so the changes take effect immediately
  1. Replace YOUR_SSH_PUBLIC_KEY_HERE with the OpenSSH key copied earlier.
  2. Replace myusername and mypassword with your desired credentials.
  3. Paste the following into meta-data:
1
local-hostname: desired-hostname

4. Creating the ISO File

  1. Open your Linux machine.
  2. Navigate to the directory where user-data and meta-data are stored:
    1
    
    cd /path/to/your/files
    
  3. Install cloud-image-utils (if not installed):
    1
    
    sudo apt install cloud-image-utils
    
  4. Create the ISO file:
    1
    
    cloud-localds seed.iso user-data meta-data
    
  5. Verify that seed.iso was created successfully.

5. Uploading the ISO to the VM

  1. Edit the VM settings.
  2. Add a CD/ROM drive.
  3. Select the previously created seed.iso.
  4. Start the VM – the configuration is now applied!

6. Troubleshooting

  • Validate cloud-init configuration:
    1
    2
    
    cloud-init schema --config-file user-data
    cloud-init schema --config-file meta-data
    
  • For further assistance, refer to the Amazon Linux 2023 official documentation.
This post is licensed under CC BY 4.0 by the author.