本文解决问题如下:

  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/

debian官网qcow2镜像修改root账号密码,开启ssh等的更多相关文章

  1. centOS7忘记密码,修改root账号密码

    centOS7忘记密码,修改root账号密码 RHEL7 的世界发生了变化,重置 root 密码的方式也一样.虽然中断引导过程的旧方法(init=/bin/bash)仍然有效,但它不再是推荐的.“Sy ...

  2. MySQL修改root账号密码

    MySQL数据库中如何修改root用户的密码呢?下面总结了修改root用户密码的一些方法   1: 使用set password语句修改 mysql> select user(); +----- ...

  3. 树莓派 - 修改pi账号密码,开启root账号

    1.修改PI账号的密码 password pi 2.开启root账号 树莓派使用的Linux是debian系统,所以树莓派启用root和debian是相同的. debian里root账户默认没有密码, ...

  4. (14)树莓派 - 修改pi账号密码,开启root账号

    https://blog.csdn.net/yoie01/article/details/45115067 1.修改PI账号的密码 password pi 2.开启root账号树莓派使用的linux是 ...

  5. jdk官网历史版本下载&Oracle账号密码

    jdk官网下载地址: https://www.oracle.com/technetwork/java/javase/archive-139210.html 账号密码: 1772885836@qq.co ...

  6. mysql允许外网访问 和修改mysql 账号密码

    mysql的root账户,我在连接时通常用的是localhost或127.0.0.1,公司的测试服务器上的mysql也是localhost所以我想访问无法访问,测试暂停. 解决方法如下: 1,修改表, ...

  7. mac 安装mysql + 修改root用户密码 + 及报Access denied for user 'root'@'localhost' (using password:YES)解决办法

    1.下载MySQL 到mysql的官网http://dev.mysql.com/downloads/mysql/然后在页面中会看到“MySQL Community Server”下方有一个“downl ...

  8. Oracle 11g 下载|Oracle 11g 官网下载|Oracle 11g 官网下载 带登录用户和密码

    本文转载自 Oracle 11g 下载|Oracle 11g 官网下载|Oracle 11g 官网下载 带登录用户和密码 oracle 下载还需要用户名我自己注册了个方便大家使用下载直接点击提示找不到 ...

  9. Ubuntu-18.04 下修改root用户密码,安装SSH服务,允许root用户远程登录,安装vsftp服务器

    修改root用户密码 打开终端,输入 sudo passwd root 指令: 安装SSH服务 ssh默认端口号是22,可以在/etc/ssh/sshd_config文件中修改 查看服务器否开启:ne ...

随机推荐

  1. PHP文件上传和下载

    第 1 章 文件上传 1.1 客户端上传设置 在 B/S 程序中文件上传已经成为一个常用功能.其目的是客户可以通过浏览器 (Browser) 将文件上传到服务器(Server)上的指定目录. 网络上常 ...

  2. 7. SOFAJRaft源码分析—如何实现一个轻量级的对象池?

    前言 我在看SOFAJRaft的源码的时候看到了使用了对象池的技术,看了一下感觉要吃透的话还是要新开一篇文章来讲,内容也比较充实,大家也可以学到之后运用到实际的项目中去. 这里我使用Recyclabl ...

  3. [Windows篇] 在windows 10上源码编译gtest 并编写CMakeLists.txt

    本文首发于个人博客https://kezunlin.me/post/aca50ff8/,欢迎阅读! compile gtest on windows 10 Guide compile gtest on ...

  4. PHP数组具有的特性有哪些

    PHP 的数组是一种非常强大灵活的数据类型.以下是PHP数组具有的一些特性: 1.可以使用数字或字符串作为数组键值 1 $arr = [1 => 'ok', 'one' => 'hello ...

  5. Java从零开始(前篇)

    前篇 自述 本人大三通信专业,咸鱼一枚,对专业所学傅里叶变换等实在提不起兴趣. 幸好略学过c系列语言,但也浅尝辄止,浑浑噩噩,深入之后被指针弄地晕头转向. 想在毕业后转行计算机,于是我下定决心从零开始 ...

  6. JavaScript笔记五

    1.条件分支语句 - switch语句 - 语法: switch(条件表达式){ case 表达式: 语句... break; case 表达式: 语句... break; case 表达式: 语句. ...

  7. 100天搞定机器学习|Day57 Adaboost知识手册(理论篇)

    Boosting算法 Boosting是一种用来提高弱分类器准确度的算法,是将"弱学习算法"提升为"强学习算法"的过程,主要思想是"三个臭皮匠顶个诸葛 ...

  8. 前端js,如何在结构化与性能中做取舍。

    js发展中的问题 随着前端web技术的发展,js要解决的问题也变得越来越多,越来越复杂. 解决更复杂的问题,需要更好的结构. 解决更复杂的问题,也需要更好的性能. 结构的优化在一定程度上会牺牲性能,同 ...

  9. nginx代理跨域,根据路径参数改变目标服务器地址

    我们都知道nginx是可以做跨域代理的: location ^~ /visited-path/ { proxy_pass http://another-domain/; } 举个例子:假如我们的代理服 ...

  10. Spring之跨重定向请求传递数据

    摘要 在开发场景中,大部分数据都是使用请求转发(forward)进行传递,而使用重定向(redirect)传递数据可能比较少. 那么问题来了:请求中的数据生命周期存活时间只在一个请求转发(reques ...