Linux开启ssh并允许root登录(ubuntu、centos、kalilinux)

1、Ubuntu开启ssh服务及允许root登录

1)安装ssh服务器端

Ubuntu默认没有安装ssh的server,需要安装

apt-get install openssh-server

ssh客户端是默认安装的,连接其它ssh服务器用的,使用 apt install openssh-client安装

2)允许远程使用root账号ssh连接本机

  • 修改/etc/ssh/sshd_config文件
vim /etc/ssh/sshd_config
  • 修改如下:允许root账户登录
#PermitRootLogin prohibit-password
PermitRootLogin yes
  • 需要重启系统或者sshd服务
sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start
sudo service ssh restart
  • 安装ssh服务后,系统默认开启系统sshd,查看sshd状态如果不是默认启动,修改服务为enable
sudo systemctl enable ssh

2、CentOS开启SSH服务及允许root登录

1)安装openssh-server

yum list installed |grep openssh-server

如果有输出,证明已经安装了openssh-server,如果没有,需要安装

yum install openssh-server

2)修改sshd服务配置文件

  • 编辑sshd服务配置文件
vim /etc/ssh/sshd_config  #没有vim用vi或者yum install -y vim 安装
  • 开启监听端口
Port 22
ListenAddress 0.0.0.0
ListenAddress ::
  • 允许远程登录
PermitRootLogin yes
  • 使用用户名密码作为验证连接
PasswordAuthentication yes

3)重启sshd服务

service sshd start
service sshd restart
  • 配置开机自启动
systemctl enable sshd

3、Kalilinux开启ssh及允许root登录

1)安装ssh服务器端

Kalilinux默认是没有安装ssh的

apt-get install openssh-server

2)修改配置让ssh允许root登录

1.配置ssh配置文件

vim /etc/ssh/sshd_config

2.找到配置

原来这行:PermitRootLogin prohibit-password
修改成这行:PermitRootLogin yes

3.保存退出,重启ssh服务

/etc/init.d/ssh restart

3)添加ssh开机自启动

1.启动ssh

/etc/init.d/ssh start
#或
systemctl  start sshd

2.查看ssh的运行状态

/etc/init.d/ssh status
#或
systemctl  status sshd

3.开机自启动配置

systemctl enable ssh.service
#或
update-rc.d ssh enable

推荐几款shh客户端连接工具

1、MobaXterm_Personal

2、electerm

3、PuTTY

4、xshell

  • 22
    点赞
  • 234
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值