Ubuntu LTS 开启SSH服务 允许远程连接

under Linux  tag     Published on June 15th , 2020 at 05:28 am

前言

Ubuntu的LTS版本默认不安装openssh-server,想要使本机开放SSH服务就要安装openssh-server

安装步骤

1. 安装ssh-server服务

# 安装 openssh 服务
sudo apt-get install openssh-server
# 启动 ssh 服务
sudo /etc/init.d/ssh start

2.开启22端口

虽然可以用命令 systemctl disable firewalld 直接关闭防火墙,但不建议这样做,推荐仅允许22端口通过防火墙:

# 若 firewalld 未安装,则先进行安装
sudo apt install firewalld
# 允许 tcp 22端口
sudo firewall-cmd --permanent --add-port=22/tcp
# 可选:允许ssh服务 
sudo firewall-cmd --permanent  --add-service=ssh
# reload 防火墙,应用规则
sudo systemctl reload firewalld

验证22端口是否开启:

sudo firewall-cmd --list-all

本文由simyng创作, 采用知识共享署名4.0 国际许可协议进行许可,转载前请务必署名
  文章最后更新时间为:June 14th , 2020 at 09:28 pm