开启计算机的ssh 22端口

当我们使用一台服务器的时候,经常需要开启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登录成功

  • 12
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一只小菜鸟-BIOS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值