修改debian官方qcow2镜像的root密码和源,并且开启ssh
在云计算中,经常碰到一个问题,我在官网下载了镜像,但是上传到openstack并创建虚拟机后,不知道用户密码,导致无法使用。
本文讲述如何修改debian官方qcow2镜像的root密码和源,并且开启ssh
1、安装必要软件
centos:
yum install wget openssl openssl-devel libguestfs libguestfs-tools -y
ubuntu:
apt-get install wget openssl libssl-dev libguestfs-tools -y
2、下载qcow2镜像
wget https://cloud.debian.org/images/cloud/OpenStack/10.13.26-20240519/debian-10.13.26-20240519-openstack-amd64.qcow2
3、生成MD5加密密码
openssl passwd -l 123456
4、挂载镜像
guestfish --rw -a debian-10.13.26-20240519-openstack-amd64.qcow2
Welcome to guestfish, the guest filesystem shell for editing virtual machine filesystems and disk images. Type: 'help' for help on commands 'man' to read the manual 'quit' to quit the shell ><fs> run ><fs> list-filesystems /dev/sda1: ext4 ><fs> mount /dev/sda1 / ><fs>
5、修改密码
><fs> vi /etc/shadow
将root:后面的第一个*替换为第三步加密之后的密码
6、开启ssh远程登录
编辑/etc/ssh/sshd_config
><fs> vi /etc/ssh/sshd_config
以下内容修改,其他不变
PermitRootLogin prohibit-password PermitRootLogin yes PasswordAuthentication yes
7、退出guestfish
><fs> quit
到此root密码修改已完成,并且开启了ssh,可以上传到openstack使用了。
24咨询热线

- 13938583546
- 微信同号
- 吴老师