virt-customize -a /opt/kvm/ubuntu18.04.qcow2 --hostname node01
5.4. 启用root ssh登录
1
virt-customize -a /opt/kvm/ubuntu18.04.qcow2 --run-command 'echo "PermitRootLogin yes" >> /etc/ssh/sshd_config'
5.5. 修改root密码
1 2 3
virt-customize -a /opt/kvm/ubuntu18.04.qcow2 --root-password password:voidking # or virt-customize -a /opt/kvm/ubuntu18.04.qcow2 --password root:voidking
5.6. 添加authorized_keys
1
virt-customize -a /opt/kvm/ubuntu18.04.qcow2 --ssh-inject root:string:"ssh-rsa xxx vk@macpro.lan"
5.7. 安装软件包
1 2
virt-customize -a /opt/kvm/ubuntu18.04.qcow2 --install vim,wget,curl,unzip virt-customize -v -x -a /opt/kvm/ubuntu18.04.qcow2 --install vim,wget,curl,unzip
# This is the network config written by 'subiquity' network: version:2 ethernets: ens3: dhcp4:false# 禁止动态IP addresses: [192.168.56.200/24] # IP地址和掩码 gateway4:192.168.56.1# 网关 nameservers: addresses: [192.168.56.1,114.114.114.114] #DNS服务器
3、使配置生效
1 2
netplan apply ip a
5.9. 手动配置静态IP2.0
1、提前准备 00-installer-config.yaml 内容为:
1 2 3 4 5 6 7 8 9 10
# This is the network config written by 'subiquity' network: version:2 ethernets: ens3: dhcp4:false# 禁止动态IP addresses: [192.168.56.200/24] # IP地址和掩码 gateway4:192.168.56.1# 网关 nameservers: addresses: [192.168.56.1,114.114.114.114] #DNS服务器
2、拷贝到宿主机
1
virt-customize -a /opt/kvm/ubuntu18.04.qcow2 --copy-in 00-installer-config.yaml:/etc/netplan/00-installer-config.yaml
5.10. 自动配置静态IP
1
virt-customize -a /opt/kvm/ubuntu18.04.qcow2 --run-command "sed -i \"s#addresses: \[.*/24\]#addresses: \[192.168.56.201/24\]#\" /etc/netplan/00-installer-config.yaml"