picture loss
  • 首页
  • 资讯
  • linux命令
  • 运维日记

-2023-

05/18

浏览 11

0
首页 > 运维日记 > 正文

debian9.X 9系列启用root登录允许root用户以SSH登录方法

在使用debian9.X系列系统中会经常使用到root用户权限,在执行一些命令或者修改系统配置的时候普通用户是没办法操作的这时候我们就需要开启root权限来操作,然后在使用中频繁切换root有会比较麻烦,在此笔戈整理了debian9系统下如何开启root登录的方法以供各位参考。

切换root权限

su

输入su接着输入root用户密码 成功切换到root用户

kk@kk-48:~$ su
Password:
root@kk-48:/home/kk#

修改SSH配置

修改SSH配置文件启用root用户密码登录 这里推荐使用nano编辑器

nano /etc/ssh/sshd_config
root@kk-48:/home/kk# nano /etc/ssh/sshd_config

GNU nano 2.7.4 File: /etc/ssh/sshd_config

ListenAddress ::

HostKey /etc/ssh/ssh_host_rsa_key

HostKey /etc/ssh/ssh_host_ecdsa_key

HostKey /etc/ssh/ssh_host_ed25519_key

Ciphers and keying

RekeyLimit default none

Logging

SyslogFacility AUTH

LogLevel INFO

Authentication:

LoginGraceTime 2m

PermitRootLogin prohibit-password #修改此处配置为 PermitRootLogin yes

StrictModes yes

MaxAuthTries 6

MaxSessions 10

PubkeyAuthentication yes

Expect .ssh/authorized_keys2 to be disregarded by default in future.

AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2

AuthorizedPrincipalsFile none

AuthorizedKeysCommand none

AuthorizedKeysCommandUser nobody

For this to work you will also need host keys in /etc/ssh/ssh_known_hosts

^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^J Justify ^C Cur Pos ^X Exit ^R Read File ^\ Replace ^U Uncut Text ^T To Spell ^_ Go To Line

需要修改的地方 找到 #PermitRootLogin prohibit-password 修改其为 PermitRootLogin yes 注意要删除掉前面的#号
以下是修改好的配置文件

#LoginGraceTime 2m
PermitRootLogin yes

StrictModes yes

MaxAuthTries 6

MaxSessions 10

最后保存提交即可 nano编辑保存文件 ctrl+x 接着按 y 确认即可

重启SSH服务

修改好配置文件以后重启SSH服务即可

/etc/init.d/ssh restart
root@kk-48:/home/kk# /etc/init.d/ssh restart

[ ok ] Restarting ssh (via systemctl): ssh.service. root@kk-48:/home/kk#

最后使用SSH工具验证root登录是否生效 以上即Debian 9允许root用户登录和以ssh方式登录的教程

- END -

debianssh

上一篇

Windows2008 2012 2016 2019 IIS7.5 8.0 10.0 一键安装脚本BAT安装脚本发布

下一篇

centos7.X 系列自定义系统安装硬盘分区教程

猜你喜欢

Centos系统修改与查看ssh端口
centos debian ubuntu等linux系统挂载多个磁盘教程
修改debian8系统语言英文为中文
centos ubuntu debian 使用fdisk工具挂载数据盘 硬盘分区 磁盘整理教程

发表评论 回复: 取消

picture loss

暂无评论,你要说点什么吗?

Copyright © 2023 biger.me All Rights Reserved

笔戈