debian官网qcow2镜像修改root账号密码,开启ssh,修改源,语法高亮等

一、准备工作

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.0 (Buster) Cloud
osinfo=debian10
arch=x86_64
file=debian-10.2.0-openstack-amd64.qcow2
checksum[sha512]=296ad8345cb49e52464a0cb8bf4365eb0b9e4220c47ebdd73d134d51effc756d5554aee15027fffd038fef4ad5fa984c94208bce60572d58b2ab26f74bb2a5de
format=qcow2
size=566434304
revision=20191116
notes=Debian 10.2.0 (Buster).

 This is a Debian installation, suited for running as OpenStack guest.

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

[[email protected] ~]# openssl passwd -1 123456
$1$HDUWloxk$IZuLRX39Oa31T4YzCrCHL1

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

guestfish --rw -a debian-10.2.0-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:*:18216:0:99999:7:::
daemon:*:18216:0:99999:7:::
bin:*:18216:0:99999:7:::
sys:*:18216:0:99999:7:::
sync:*:18216:0:99999:7:::
games:*:18216:0:99999:7:::
man:*:18216:0:99999:7:::
lp:*:18216:0:99999:7:::
mail:*:18216:0:99999:7:::
news:*:18216:0:99999:7:::
uucp:*:18216:0:99999:7:::
proxy:*:18216:0:99999:7:::
www-data:*:18216:0:99999:7:::
backup:*:18216:0:99999:7:::
list:*:18216:0:99999:7:::
irc:*:18216:0:99999:7:::
gnats:*:18216:0:99999:7:::
nobody:*:18216:0:99999:7:::
_apt:*:18216:0:99999:7:::
systemd-timesync:*:18216:0:99999:7:::
systemd-network:*:18216:0:99999:7:::
systemd-resolve:*:18216:0:99999:7:::
messagebus:*:18216:0:99999:7:::
unscd:*:18216:0:99999:7:::
ntp:*:18216:0:99999:7:::
sshd:*:18216:0:99999:7:::

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

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

root:$1$HDUWloxk$IZuLRX39Oa31T4YzCrCHL1:18216:0:99999:7:::

三、开启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(1) 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 022

# 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(1) 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 022

# 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‘

最后执行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/

原文地址:https://www.cnblogs.com/nihaorz/p/12058364.html

时间: 2024-08-27 16:23:23

debian官网qcow2镜像修改root账号密码,开启ssh,修改源,语法高亮等的相关文章

MySQL修改root账号密码的方法

MySQL修改root账号密码的方法 MySQL数据库中如何修改root用户的密码呢?下面总结了修改root用户密码的一些方法 1: 使用set password语句修改 mysql> select user();+----------------+| user() |+----------------+| root@localhost |+----------------+1 row in set (0.08 sec) mysql> set password=password('123456

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

1.修改PI账号的密码 [plain] view plain copy print? password pi 2.开启root账号 树莓派使用的Linux是debian系统,所以树莓派启用root和debian是相同的. debian里root账户默认没有密码,但账户锁定.当需要root权限时,由默认账户经由sudo执行,Raspberry pi 系统中的Raspbian默认用户是pi 密码为raspberry重新开启root账号,可由pi用户登录后,在命令行下执行 [plain] view p

无密码登入系统,修改root账号密码

如果忘了系统登入密码怎么办呢 ? 那么今天我们就来解决下该问题 首先开启机器按 "e" 进入如下界面   再按"e" 键进入如图 再 按ENTER 退回到 再按"b" 重启 不用密码进入系统 执行 passwd root 修改root 密码 即可

Centos7.3系统 之 重置Root账号密码

Centos 7版本系统如何重置root 账号密码 问题:centos系统的root账号的密码遗忘,怎么办呢? 处理办法: 1.需要对服务器进行重启操作,在开机界面grub菜单,通过上下键选择启动项 2.选中后,输入字母"e" 3.大概在16行左右,将ro 改为rw init=/sysroot/bin/sh 保存并退出 4.现在按下control+x,将使用单用户模式启动. 5.输入以下命令 1)chroot    /sysroot 2)修改密码    passwd  root 3)更

RHEL7修改root用户密码

linux中忘记管理员密码是很麻烦的事情,RHEL5和RHEL6中修改root用户密码我们都已经很熟悉了,下面说一下RHEL7中修改root密码; 重新启动RHEL7,到启动菜单按e键: 找到linux16开始的行,按end键把光标移动到该行的末尾 在该行的末尾添加rd.break,然后按ctrl+x组合键启动系统: 进入命令提示符后连续输入命令,如图: 关闭selinux,修改/etc/selinux/config配置文件,把SELINUX=enforcing修改为SELINUX=disabl

在虚拟机下安装ubuntu 10.04 64bit,并修改root用户密码

实验的环境: 笔记本是:HP 虚拟机:VMware  9 准备安装的操作系统: ubuntu 10.04  64bit 实验步骤: 一:让自己的hp支持虚拟化技术(由于ubuntu 10.04  64bit需要CPU支持虚拟化技术,所以要通过bios来更改电脑的默认设置) 启动时根据提示按 Esc 键 按 F10 键以配置 BIOS 使用箭头键滚动到"System Configuration" 选择"Virtualization Technology",然后按 En

mysql-8.0.16-winx64/Linux修改root用户密码

连接数据库等基础操作请自行解决哈,本篇是重点记录如何改密码. 一.查询用户密码: 查询用户密码命令: select host, user, authentication_string from mysql.user ; host:允许用户登录的ip‘位置'%表示可以远程: user:当前数据库的用户名: authentication_string:用户密码(后面有提到此字段): 二. 设置(或修改)用户密码: 默认root密码为空的话 ,下面使用navicat就无法连接(之前我装的5.7好像还可

Kali Linux 2020.1快速修改root用户密码

Kali Linux 2020.1快速修改root用户密码 安装Kali Linux 2020.1系统过程中,将要求创建一个普通用户.而且,在安装过程中没有设置过root密码.由于大部分软件需要root用户权限才可以安装,为了方便使用kali系统,可以为root用户设置密码,并使用root用户登录系统.大学霸IT达人当用户使用普通用户登录后,则可以在终端使用sudo passwd命令快速修改root用户密码.在XFCE桌面中,操作方法如下: C:\home\test> sudo passwd r

Ubuntu 14.04 为 root 帐号开启 SSH 登录

原文:Ubuntu 14.04 为 root 帐号开启 SSH 登录 1. 修改 root 密码 sudo passwd root 2. 以其他账户登录,通过 sudo nano 修改 /etc/ssh/sshd_config : [email protected]:~$ su - root Password: [email protected]:~# vi /etc/ssh/sshd_config 3. 注释掉 #PermitRootLogin without-password,添加 Perm