一、單用戶模式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 ~]#