本文解决问题如下:

  1. 设置root账号密码
  2. 开启root账号ssh连接
  3. 开启ssh语法高亮
  4. 解决vi编辑界面不允许复制问题

一、准备工作

1、下载官网qcow2镜像文件

wget https://cloud.debian.org/images/cloud/OpenStack/10.2.0/debian-10.2.0-openstack-amd64.qcow2

镜像文件信息

[debian-10.2-cloud]
name=Debian 10.2. (Buster) Cloud
osinfo=debian10
arch=x86_64
file=debian-10.2.-openstack-amd64.qcow2
checksum[sha512]=296ad8345cb49e52464a0cb8bf4365eb0b9e4220c47ebdd73d134d51effc756d5554aee15027fffd038fef4ad5fa984c94208bce60572d58b2ab26f74bb2a5de
format=qcow2
size=
revision=
notes=Debian 10.2. (Buster). This is a Debian installation, suited for running as OpenStack guest.

2、使用openssl passwd -1 生成加密的密码:-1表示使用MD5算法对密码进行加密

[root@support01 ~]# openssl passwd -
$$HDUWloxk$IZuLRX39Oa31T4YzCrCHL1

3、使用guestfish命令进入交互命令界面依次执行run、list-filesystems、mount等指令

guestfish --rw -a debian-10.2.-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>

二、修改root账号密码

编辑/etc/shadow

><fs> vi /etc/shadow
root:*:::::::
daemon:*:::::::
bin:*:::::::
sys:*:::::::
sync:*:::::::
games:*:::::::
man:*:::::::
lp:*:::::::
mail:*:::::::
news:*:::::::
uucp:*:::::::
proxy:*:::::::
www-data:*:::::::
backup:*:::::::
list:*:::::::
irc:*:::::::
gnats:*:::::::
nobody:*:::::::
_apt:*:::::::
systemd-timesync:*:::::::
systemd-network:*:::::::
systemd-resolve:*:::::::
messagebus:*:::::::
unscd:*:::::::
ntp:*:::::::
sshd:*:::::::

将root:后面的第一个*替换为第二步加密之后的密码

替换后第一行为/etc/shadow第一行为

root:$$HDUWloxk$IZuLRX39Oa31T4YzCrCHL1:::::::

三、开启root账号ssh远程登录

编辑/etc/ssh/sshd_config,在vi中:set number开启行号

><fs> vi /etc/ssh/sshd_config

第32行

#PermitRootLogin prohibit-password

释放掉注释,并修改值为yes,调整完之后第32行为

PermitRootLogin yes

第56行

#PasswordAuthentication yes

释放掉注释,调整完之后第56行为

PasswordAuthentication yes

四、修改apt源,(qcow2注册到OpenStack之后启动虚拟机源还是默认的,目前原因未知,可待虚拟机启动后执行下列修改)

编辑/etc/apt/sources.list,将替换为以下内容

deb http://mirrors.163.com/debian/ buster main contrib non-free
# deb-src http://mirrors.163.com/debian/ buster main contrib non-free
deb http://mirrors.163.com/debian/ buster-updates main contrib non-free
# deb-src http://mirrors.163.com/debian/ buster-updates main contrib non-free
deb http://mirrors.163.com/debian/ buster-backports main contrib non-free
# deb-src http://mirrors.163.com/debian/ buster-backports main contrib non-free
deb http://mirrors.163.com/debian-security buster/updates main contrib non-free
# deb-src http://mirrors.163.com/debian-security buster/updates main contrib non-free

五、开启ssh语法高亮以及内置命令别名

编辑/root/.bashrc,1、3、4、8、15行为说明注释,除此之外释放所有注释

><fs> vi /root/.bashrc

编辑之前内容为:

# ~/.bashrc: executed by bash() for non-login shells.

# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask # You may uncomment the following lines if you want `ls' to be colorized:
# export LS_OPTIONS='--color=auto'
# eval "`dircolors`"
# alias ls='ls $LS_OPTIONS'
# alias ll='ls $LS_OPTIONS -l'
# alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'

编辑之后内容为:

# ~/.bashrc: executed by bash() for non-login shells.

# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
umask # You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

六、允许在vi窗口中复制文本

><fs> vi /usr/share/vim/vim81/defaults.vim

78、79、80三行内容为:

if has('mouse')
set mouse=a
endif

在“=”前面添加一个“-”,编辑后内容为:

if has('mouse')
set mouse-=a
endif

最后执行quit命令退出guestfish,将qcow2镜像文件注册到openstack,投递虚拟机实例即可

参考链接:

https://docs.openstack.org/image-guide/modify-images.html#guestfish

https://blog.51cto.com/superzhangqiang/1705678

https://blog.csdn.net/weixin_42551369/article/details/88946622

http://www.chenshake.com/openstack-mirror-and-password/

最新文章

  1. struts2学习之旅三 权限管理和导航设计
  2. web加密的基本概念
  3. Map接口,Map.Entry,hashMap类,TreeMap类,WeakHashMap。
  4. express+gulp构建项目(四)env环境变量
  5. crontab日常使用梳理
  6. HDU 1069 基础动态规划+排序
  7. fzu 1015 土地划分(判断线段相交+求出交点+找规律)
  8. qt 5 小练习 简易画板
  9. 解决拼团首页swiper组件手动轮播卡顿问题
  10. poj3308
  11. seajs加载angularjs
  12. window 使用git 非ssh key 面密码登录
  13. dubbo2.5.6从下载到编译成功并且部署成功过程
  14. Hello,World!!----来自半个新OIer的问候
  15. 11.3、Libgdx的音频之播放PCM音频
  16. Vim配置(python版)
  17. maven构建SSM框架中pom.xml文件配置
  18. RecyclerView拖拽排序;
  19. 5. Tomcat窗口标题修改
  20. 进阶之路(基础篇) - 001 亮一个led灯

热门文章

  1. hdu 1205 吃糖果 (抽屉原理&lt;鸽笼原理&gt;)
  2. nyoj 60-谁获得了最高奖学金 (逻辑判断)
  3. C语言|博客作业07
  4. linux启动与登录
  5. 十、GAP
  6. Mac的Safari安装油猴插件(Tampermonkey)
  7. Centos7 搭建LAMP环境(编译安装)
  8. java引用知识
  9. 进入编辑模式、vim命令模式、vim实践
  10. iOS 一些struct类型的NSLog输出格式