Multipass
管理多ubuntu实例,进行模拟分布式、网络编程实验
Install https://canonical.com/multipass/install Document : https://documentation.ubuntu.com/multipass/latest/
Launch an instance (by default you get the current Ubuntu LTS):
bashmultipass launch --name fooRun commands in that instance, try running bash (logout or ctrl-d to quit):
bashmultipass exec foo -- lsb_release -aSee your instances:
bashmultipass listStop and start instances:
bashmultipass stop foo barbashmultipass start fooClean up what you don't need:
bashmultipass delete barbashmultipass purgeFind alternate images to launch:
bashmultipass findPass a cloud-init metadata file to an instance on launch. (See Using cloud-init with Multipass for more details):
bashmultipass launch -n bar --cloud-init cloud-config.yamlGet help:
bashmultipass helpbashmultipass help <command>
示例
bash
multipass networks //查看物理网卡
$ Name Type Description
$ WLAN wifi Intel(R) Wi-Fi 6 AX201 160MHzbash
multipass launch 25.04 --name u25-node1 --network WLAN
multipass launch 25.04 --name u25-node1 --cpus 1 --memory 2G --disk 10G --network WLAN
//指定镜像版本号,实例名称,网卡SSH 连接 Multipass Ubuntu实例
默认无初始化账密登录,使用公钥登录
查询已有公钥
bash
multipass exec u25-node2 -- cat /home/ubuntu/.ssh/authorized_keys写入本机公钥
bash
//查询本机公钥
type %USERPROFILE%\.ssh\id_ed25519.pub
//写入公钥
multipass exec u25-node2 -- bash -c "echo '<具体公钥>' >> /home/ubuntu/.ssh/authorized_keys"
//更新权限
multipass exec u25-node2 -- sudo chown ubuntu:ubuntu /home/ubuntu/.ssh/authorized_keys
multipass exec u25-node2 -- sudo chmod 600 /home/ubuntu/.ssh/authorized_keysVisual Studio Code ssh 配置
json
Host u25-node2
HostName 192.168.1.6
User ubuntu