配置树莓派(Raspberry Pi)上Raspbian系统为自动以root帐户登录(免密码登录)
2018-03-30 18:49
916 查看
转载: https://blog.csdn.net/w_z_z_1991/article/details/52060364
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
After=systemd-user-sessions.service plymouth-quit-wait.service
After=rc-local.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes
# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by serial-getty@.service, not this
# unit.
ConditionPathExists=/dev/tty0
[Service]
# the VT is cleared by TTYVTDisallocate
ExecStart=-/sbin/agetty --noclear %I $TERM
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes 36 TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes
# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPH ONE= LC_MEASUREMENT= LC_IDENTIFICATION=
[Install]
WantedBy=getty.target
DefaultInstance=tty1
解锁raspibian系统的root帐号
正常情况下,Raspbian系统默认并没有开启
root帐户,首先需要开启
root帐户。先使用
pi帐户登录系统(默认密码是:
raspberry),然后执行下面的命令:
localhost:~ wangzhizhou$ ssh pi@192.168.0.110 pi@192.168.0.110's password: The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Thu Jul 28 16:04:49 2016 from 192.168.0.109 pi@raspberrypi:~ $ sudo passwd root Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully pi@raspberrypi:~ $ sudo passwd --unlock root passwd: password expiry information changed. pi@raspberrypi:~ $ su root Password: root@raspberrypi:/home/pi# vi /etc/systemd/system/getty.target.wants/getty\@tty1.service
查看系统启动相关配置文件
打开系统登录配置文件,内容如下: # This file is part of systemd.#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
After=systemd-user-sessions.service plymouth-quit-wait.service
After=rc-local.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes
# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by serial-getty@.service, not this
# unit.
ConditionPathExists=/dev/tty0
[Service]
# the VT is cleared by TTYVTDisallocate
ExecStart=-/sbin/agetty --noclear %I $TERM
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes 36 TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes
# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPH ONE= LC_MEASUREMENT= LC_IDENTIFICATION=
[Install]
WantedBy=getty.target
DefaultInstance=tty1
修改系统配置文件
我们只要把第28行从:ExecStart=-/sbin/agetty --noclear %I $TERM改为:ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM保存后,重启就可以自动以root用户登录了。(如果改为其他用户,将以那个设置的用户免密码登录树莓派。亲测可行。)
后记
在比较后的raspbian系统中,SysV系统中使用/etc/inittab文件来管理相关配置,所以在网上查的资料大部分是
关于这个文件设置的,较新的系统一般使用了systemd来管理相关配置,所以配置文件已经变以了博文中所修改的那个文件了。-_-#
相关文章推荐
- 配置Raspberry Pi上Raspbian系统为自动以root帐户登录
- 为树莓派(Raspberry pi 2)安装raspbian系统,并用windows自带的远程桌面连接登录
- ubuntu10.04.04系统 设置root用户默认登录用户,并设定成无需密码认证自动登录
- 新版raspbian系统的固定IP配置和启用root账户的ssh登录功能的方法
- Ubuntu10.04设置开机自动登入root帐户(不要密码登录)|| Ubuntu14.04root登录|| Ubuntu12.04root登录
- 树梅派应用49:配置树莓派自动登录 Raspbian 图形界面 LXDE
- 为树莓派(Raspberry pi 2)安装raspbian系统,并用windows自带的远程桌面连接登录
- mysql配置的讲解 mysql的root密码重置 mysql的登录
- mysql配置的讲解 mysql的root密码重置 mysql的登录
- linux进入系统后root帐号不能登录,密码正确就是不登录
- Linux系统在未登录的情况下修改root密码方法(linux系统忘记root密码,进不去系统怎么办)
- 【原创】Linux 系统移植日志----登录账户,密码配置
- Ubuntu root用户自动登录系统
- 怎样修改Ubuntu的root帐户密码并使用root登录
- Linux 系统的单用户模式、修复模式、跨控制台登录在系统修复中的运用及突破root密码的方法
- java 传入用户名和密码并自动提交表单实现登录到其他系统
- Ubuntu root用户自动登录系统
- Android系统编译环境搭建—Ubuntu14.04安装&root登录&Chromium root启动&安装配置交叉编译环境
- 输入密码登录系统后又自动注销?原来是机器狗惹的祸2
- ubuntu10.04 LTS root 不键入密码 自动登录