您的位置:首页 > 编程语言 > ASP

配置树莓派(Raspberry Pi)上Raspbian系统为自动以root帐户登录(免密码登录)

2018-03-30 18:49 916 查看
转载: https://blog.csdn.net/w_z_z_1991/article/details/52060364

解锁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来管理相关配置,所以配置文件已经变以了博文中所修改的那个文件了。-_-#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐