当前位置: 首页> 房产> 政策 > 开启计算机的ssh 22端口

开启计算机的ssh 22端口

时间:2025/7/13 17:47:08来源:https://blog.csdn.net/qq_43561214/article/details/142052772 浏览次数:0次

当我们使用一台服务器的时候,经常需要开启ssh 服务,有些系统没有默认开启服务,需要需要我们做一些配置,以下是完整配置过程和错误解决方法:

以下过程适合于当我们购买一台云主机时候配置远程登录

开启本地计算机的22端口

Failed to restart sshd.service: Unit sshd.service not found

1、 查看是否安装 openssh-serveryum list installed | grep openssh-server

yum install openssh-server 安装sshd服务

Ubuntu : apt-get install openssh-server 安装sshd服务

3、进入/etc/ssh/目录下找到配置文件sshd_config,用Vim编辑器打开。命令 vim sshd_config,修改以下内容

设备端口 ssh 端口22

3.2、开启允许远程登录

PermitRootLogin yes

3.3、开启使用用户名密码来作为连接验证

PasswordAuthentication yes

systemctl start sshd.service && systemctl enable sshd.service

root@xxx:~# sudo service sshd restart

Failed to restart sshd.service: Unit sshd.service not found.

第五步,执行重启命令

root@xxx:~# systemctl enable ssh.service

Synchronizing state of ssh.service with SysV service script with /lib/systemd/systemd-sysv-install.

Executing: /lib/systemd/systemd-sysv-install enable ssh

Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service.

第六步以及第七步,查看端口号

root@xxx:~# service sshd start

root@xxx:~# ss -ntl

State    Recv-Q    Send-Q        Local Address:Port        Peer Address:Port   

LISTEN   0         128                 0.0.0.0:22               0.0.0.0:*      

LISTEN   0         128                    [::]:22                  [::]:*  

启动sshd失败,报错:Failed to start OpenBSD Secure Shell server

 

  1. apt-get install openssh-server openssh-client
  2. 执行  /etc/init.d/ssh start
  3. 报错 Could not resolve hostname start

          ss -ntl    22端口打开

  1. 远程ssh登录成功

关键字:开启计算机的ssh 22端口

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: