一、单用户模式linux
鼠标右击、电源 、从新启动客户机,点击肯定shell
在从新启动的那一刻按动一下上下方向键,注意不要按回车,仅仅按上下方向键安全
press"e"to edit the selected item or "c"for a command promptbash
按e编辑选定的项目或c以得到命令提示符, 按e 等于edit,去编辑选择的dom
用上下方向键定位到Linux16这行 用向右方向键移动到ro。ssh
并把ro更改成 rw init=sysroot/bin/shide
输入#chroot /sysroot/ 回车 从安全模式下切换到原来的系统模式,才可使用原来的系统命令,修改密码ui
输入#passwd root 出现乱码,ctrl+c取消passswd root ,命令spa
输入#LANG=en 定义源为英文,由于不支持中文code
再输入#passwd root
输入新密码,再次确认新密码,
在输入#touch /.autorelabel 这一步很关键,不能忘记
重启。依照第一步,右击电源 从新启动客户机 以上操做均不能远程操做
二、求援模式
init 0 或者 shutdown now 关闭虚拟机linux 编辑虚拟机设置挂在光驱 ,要勾选启动时链接,以下图
点击虚拟机 电源,启动时进入固件,有的叫BIOS 以下图
目的是为了从BIOS里面把光驱调为第一启动项,默认不是
选择BOOT 把光驱按加号往上排。按F10保存重启
选择Troubleshooting 解决故障这个选项
进入后选择第二项Rescue a centOS Linux system 回车
再按回车
会进来这个界面 选1继续 please make a selection fro the above:1
1continue 继续
2只读挂载read only mount
3跳过这个SHELL skip to shell
4重启 quit reboot
按回车,
按回车后
输入#chroot /mnt/sysimage/ 回车(好比改错配置文件致使系统不能开机,能够用此方法改正确在开机)
再输入#psswd root 修改root密码, 输入新密码,再次输入新密码 点击右下角光盘断开光驱重启
点击是 重启
三、克隆虚拟机
虚拟机关机 init 0 或者shutdown now
修改主机名,从新登陆
[root@izj6c3jotxcj524e29g764z ~]# hostnamectl set-hostname chamhk [root@izj6c3jotxcj524e29g764z ~]# logout
四、Linux机器相互登陆
把克隆好的虚拟机更改一个不一样的ip ,cham2ip192.168.230.135,cham3ip192.168.230.140, 避免冲突 开启原克隆的虚拟机,一共两台,用Xshell 链接上
用cham3去链接cham2 #ssh -p 22 192.168.230.135 在cham3用#w 命令查看,在cham2也同样
显示链接的用户帐户以及IP
CTRL+D退出
密钥链接
cham2链接cham3 [root@cham2 ~]# ssh -keygen Bad escape character 'ygen'. [root@cham2 ~]# [root@cham2 ~]# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: ac:bf:25:89:b1:e4:4e:40:8e:d8:4e:02:0a:54:b4:df root@cham2 The key's randomart image is: +--[ RSA 2048]----+ | .oo | |. . | |o .. | |+o +. .. | |+ + o.oES | | + + = . | | . * o . | | o . o | | . o. | +-----------------+ [root@cham2 ~]# [root@cham2 ~]# [root@cham2 ~]# [root@cham2 ~]# ls /root/.ssh/ id_rsa id_rsa.pub [root@cham2 ~]# ls / bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var [root@cham2 ~]# ls -a / . .autorelabel boot etc lib media opt root sbin sys usr .. bin dev home lib64 mnt proc run srv tmp var [root@cham2 ~]# ls -a /root . .. anaconda-ks.cfg .bash_history .bash_logout .bash_profile .bashrc .cshrc .ssh .tcshrc [root@cham2 ~]# cat /root/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCY9njGjCryW99bp7cIhWJCHx08BVmZjYu90yO666sfZLJ5PIINOlu6d0IXZ7Swqxm3UYw2oexzEuWP0Cg+FqWRtSGkDAGfWurLpkNj0H+RN9/fen3cBUg0SOyHf95HhCJj+PZns8IXwVvx0PxuJkN4q3U44jy/dCFUvnR3sSm2ZSHYVDxgE/msW3refSdxJ6fgxye8TpVeAAsQoylQhhwhJ+tMyS93EZhKIJa9ilMgrYc2zMjZWnJMSlcCkvw7A4ZcWA9E09GJjR+ZfZZ/THtrxc3B7nw9pDizeeJVPYpd9IpGOPu/ONgqJG55NQ8K6J3Oj409Dl6+1PoAjIyX1nEj root@cham2
cham3的操做
[root@cham3 ~]# vi /root/.ssh/authorized_keys [root@cham3 ~]#
cham2的操做
[root@cham2 ~]# ssh 192.168.230.140 The authenticity of host '192.168.230.140 (192.168.230.140)' can't be established. ECDSA key fingerprint is 17:30:54:67:53:da:68:83:86:d4:5e:9d:ce:e7:15:26. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.230.140' (ECDSA) to the list of known hosts. Last login: Thu Oct 19 12:20:38 2017 from 192.168.230.135 [root@cham2 ~]#