Ubuntu安装ssh远程登录

安装ssh远程登录

# 更新软件源
sudo apt-get update
# 安装openssh-server
sudo apt-get install openssh-server
# 验证ssh服务是否启动
sudo systemctl status ssh
# 未启动执行以下命令
sudo /ect/init.d/ssh start
# 修改ssh登录配置,开放22端口
sudo vim /etc/ssh/sshd_config
# 将 Port 22和 PermitRootLogin前的#去掉
# 重启ssh服务
sudo systemctl restart ssh
# 防火墙放行ssh
sudo ufw allow ssh
# (可选) 禁用ssh服务器
sudo systemctl disable --now ssh
# (可选) 启用ssh服务器
sudo systemctl enable --now ssh