1、下载 SSH 软件
1sudo apt update
2sudo apt install openssh-server
2、查看 SSH 状态、设置开启自启
1# 查看ssh状态
2sudo systemctl status ssh
3
4# 设置
5sudo systemctl enable --now ssh
3、防火墙放行 ssh
1sudo ufw allow ssh
4、连接 ubuntu
在另一台电脑的 shell 中输入如下命令,username 为登陆用户名,ip 为登陆服务器 IP 地址。
1ssh username@ip
查看 ubuntu IP 地址的方法
1ip addr
5、启动/禁止 ssh 服务
要在 Ubuntu 系统上禁用 SSH 服务器,只需运行以下命令即可停止 SSH 服务:
1# 禁用
2sudo systemctl disable --now ssh
3# 启用
4sudo systemctl enable --now ssh