zoukankan      html  css  js  c++  java
  • Ubuntu启用root账号登录系统

    使用root账号登陆Ubuntu系统,实现起来本身没啥难度,运行passwd root即可,然后在/etc/ssh/sshd_config里面修改PermitRootLogin yes即可。不过研究的过程中发现一点有趣的东西,记录一下。

    1. /etc/passwd文件中第二栏表示密码,用x表示;/etc/shadow文件中的第二栏,!表示用户禁用了。!!表示帐号目前没有密码,也不能用来登录,通常为一些系统帐号。*表示账号无法登入。

    2. root账号默认是lock状态的,若在未设置密码的情况下执行passwd --unlock root,会提示如下信息:

    passwd: unlocking the password would result in a passwordless account.
    You should set a password with usermod -p to unlock the password of this account.

    3. 于是我尝试执行usermod -p PASSWORD root,然后发现/etc/shadow文件里居然记录了明文密码PASSWORD!

    root@ubuntu:/home/testuser# head -n 1 /etc/shadow
    root:PASSWORD:17343:0:99999:7:::

    4. 但此时你依旧无法登陆,原因是你得把明文密码变成密文的:echo 'root:PASSWORD' | chpasswd (这样看起来第三步就是多余的了)

    5. chpasswd也有一些参数,比如指定以何种算法加密密码,不同的加密方式对应的shadow文件中的格式也不同,比如:$1$打头代表用MD5加密,$6$代表用SHA512加密

    6. 设置密码后再禁用账号的话,会在密码栏的密文前加一个!感叹号

  • 相关阅读:
    Pandas 基础(8)
    Pandas 基础(7)
    Pandas 基础(6)
    Pandas 基础(5)
    Pandas 基础(4)
    python matplotlib 图表局部放大
    python 带小数点时间格式化
    emacs elpy代码补全功能
    spacemacs 初始安装报错
    视频加载logo 2
  • 原文地址:https://www.cnblogs.com/IvanChen/p/4525556.html
Copyright © 2011-2022 走看看