Linux开启ssh

Linux 开启 ssh

一、Kalilinux 开启 ssh

添加 ssh 开机自启动

1.查看 ssh 的运行状态

/etc/init.d/ssh status

2.启动 ssh

/etc/init.d/ssh start

3.开机自启动配置

systemctl enable ssh.service2.或update-rc.d ssh enable

修改配置让 ssh 允许 root 登录

1.配置 ssh 配置文件

vi /etc/ssh/sshd_config

2.找到配置

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

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

/etc/init.d/ssh restart

二、CentOS 开启 SSH 服务

1.安装 openssh-server

yum list installed |grep openssh-server

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

yum install openssh-server

2.修改 sshd 服务配置文件

  • 编辑 sshd 服务配置文件
vi /etc/ssh/sshd_config
  • 开启监听端口

    Port 22
    ListenAddress 0.0.0.0
    ListenAddress ::
    
  • 允许远程登录

    PermitRootLogin yes
    
  • 使用用户名密码作为验证连接

    PasswordAuthentication yes
    
  • 开启 sshd 服务

    service sshd start
    
  • 配置开机自启动

    systemctl enable sshd