#查看IP
ip addr show
#简略版
ip -br a
Ubuntu Cloud Images - the official Ubuntu images for public clouds, Openstack, KVM and LXD
Ubuntu 24.04 LTS (Noble Numbat) release [20240423]
#meta-data文件内容:
instance-id: iid-local01
local-hostname: ubuntu-vm
#user-data文件内容:
#-------------------------(↓开始复制)
#cloud-config
users:
- name: ubuntu
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: sudo
shell: /bin/bash
plain_text_passwd: 'ubuntu'
lock_passwd: false
ssh_pwauth: True
chpasswd:
expire: False
write_files:
- path: /etc/ssh/sshd_config.d/60-cloud-init.conf
content: |
PasswordAuthentication yes
PermitRootLogin no
ChallengeResponseAuthentication no
UsePAM yes
AcceptEnv LANG LC_*
- path: /etc/sudoers.d/99-cloud-init-nodns
content: |
Defaults !fqdn
permissions: '0440'
runcmd:
- systemctl restart ssh
mkisofs.exe -o cloud-init.iso -V cidata -r -J user-data meta-data
#vmdk
qemu-img convert -f qcow2 -O vmdk input.img output.vmdk
#vhdx
qemu-img convert -f raw -O vhdx input.img output.vhdx
#vhd
qemu-img convert -f vpc -O vhdx input.vhd output.vhdx
#编辑SSH设置
sudo nano /etc/ssh/sshd_config
#修改这两项
PasswordAuthentication yes
PermitRootLogin no #开启root权限需要改成yes
#特别注意!!!在/etc/ssh/sshd_config.d/ 中有一个文件(如 60-cloudimg-settings.conf)
#PasswordAuthentication no 改为 yes
cd /etc/ssh/sshd_config.d/
sudo nano /etc/ssh/sshd_config.d/60-cloudimg-settings.conf
#保存后执行
sudo systemctl restart ssh
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7891