0. 说明 链接到标题
- openssh:在 Ubuntu 上开启 SSH 服务,让别人可以远程连接
- Tailscale:创建一个虚拟局域网,让不同网络下的设备“像在同一局域网中一样”通信
- tetermius:SSH 客户端,让你在一台电脑上通过 SSH 登录另一台电脑
1. 安装 链接到标题
1.1 openssh 链接到标题
- 安装 openssh
sudo apt update
sudo apt install openssh-server
- 启动服务
sudo systemctl enable ssh #可选开机启动
sudo systemctl start ssh #打开
- 查看服务状态
sudo systemctl status ssh #查询
- 关闭服务
sudo systemctl stop ssh #关闭
1.2 tailscale 链接到标题
- 安装 tailscale
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
# 会打开网页让你登录(用 GitHub、Google 登录都行)
- 查看分配的 Tailscale IP 地址:
tailscale ip -4
- 查看联网状态
tailscale status
- 退出虚拟局域网
tailscale down
1.3 termius 链接到标题
2. 配置 链接到标题
2.1 openssh & tailscale 链接到标题
两台电脑都打开ssh。两台电脑都打开tailscale 并登录到虚拟局域网
2.2 termius 链接到标题
- 密码登录
字段 | 内容说明 |
---|---|
Label | 自定义名称,如 Ubuntu @ Tailscale |
Address | 填入你的 Tailscale IP,比如:100.96.31.25 |
Port | 22 (默认 SSH 端口) |
Username | xxx (你在 Ubuntu 上的用户名) |
Password | 你的 Ubuntu 登录密码,或使用 SSH 私钥 |
- 密钥登录(麻烦点)
(1). 打开左侧的 Keys 面板
(2). 点击 Generate Key(或导入已有私钥)
(3). 把生成的公钥复制出来(以
ssh-rsa
或ssh-ed25519
开头)