开启root的SSH权限

最近ssh远程登录树莓派进行开发,有时候会出现pi用户权限不够的情况,就想用root用户ssh登录。

login as: pi
[email protected]'s password:
Linux RevPi21592 4.9.76-rt60-v7+ #1 SMP PREEMPT RT Fri, 28 Feb 2020 15:17:03

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: Tue Mar 24 15:46:16 2020 from 172.26.30.37
pi@RevPi21592:~ $

结果报错

login as: root
[email protected]'s password:
Access denied
[email protected]'s password:

于是决定记录下如何开启root的ssh权限

  • 在用pi登录ssh以后,切换到root用户,编辑/etc/ssh/sshd_config设置

在Authentication设置的部分,写入:PermitRootLogin yes, 保存

开启root的SSH权限_第1张图片

  • 重启ssh服务器
root@RevPi21592:/home/pi# service sshd restart
root@RevPi21592:/home/pi#

 

打开一个新的session窗口,就可以用root进行ssh登录啦

login as: root
[email protected]'s password:
Linux RevPi21592 4.9.76-rt60-v7+ #1 SMP PREEMPT RT Fri, 28 Feb 2020 15:17:03 +0100 armv7l

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.
root@RevPi21592:~#

同理,若要关闭root的ssh权限,把刚才编辑的那一行删除,或者改成no,然后重启ssh服务器即可生效

你可能感兴趣的:(开启root的SSH权限)