SSH访问指引
1.针对Windows用户:需要先装OpenSSH。判断OpenSSH Client是否安装:
| Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
|
如果看到类似输出即Client已安装
| Name : OpenSSH.Client~~~~0.0.1.0
State : Installed # 如果此处为installed说明已安装
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent```
|
如果为NotPresent,执行以下操作:
| Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
|
如果看到以下输出说明已安装:
| Path :
Online : True
RestartNeeded : False
|
Linux一般自带ssh,可以直接跳过。
2.进入powershell或bash(此时默认处于用户目录层级),然后(针对windows)
| touch config
notepad config
|
针对linux
无论哪种操作系统,都会弹出一个编辑器。在该编辑器中粘贴以下内容:
| Host cloud-jump
HostName 43.138.83.226
User ubuntu
IdentityFile 你的系统用户目录/.ssh/TXY_SECRET.pem
Host pfa-nas
HostName 10.168.1.139
Port 51222
User 改成你的NAS用户名
Host pfa-nas-external
HostName localhost
Port 22000
User 改成你的NAS用户名
ProxyJump cloud-jump
|
然后保存。
简单解释一下:我在腾讯云上租了个跳板机(就是cloud-jump),已经配置了端口转发,可以直接从外网访问NAS(通过pfa-nas-external)。访问跳板机需要私钥文件,这个文件可以在NAS根目录/wiki/private_key/TXY_SECRET.pem下载,下完之后放到你的用户目录/.ssh下即可。
添加ssh host之后建议先访问跳板机进行测试:
如果出现下列输出说明连接成功:
| PS C:\Users\USERNAME\.ssh> ssh cloud-jump
Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-130-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Thu Jun 19 02:28:08 PM CST 2025
System load: 0.0 Processes: 110
Usage of /: 13.8% of 39.26GB Users logged in: 0
Memory usage: 19% IPv4 address for eth0: 10.2.24.6
Swap usage: 0%
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
New release '24.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Thu Jun 19 14:06:07 2025 from 36.248.247.254
ubuntu@VM-24-6-ubuntu:~$
|
成功之后即可测试NAS外部连接:
如果出现以下结果说明连接成功:
| PS C:\Users\USERNAME\.ssh> ssh pfa-nas-external
Administrator_@localhost's password:
Using terminal commands to modify system configs, execute external binary
files, add files, or install unauthorized third-party apps may lead to system
damages or unexpected behavior, or cause data loss. Make sure you are aware of
the consequences of each command and proceed at your own risk.
Warning: Data should only be stored in shared folders. Data stored elsewhere
may be deleted when the system is updated/restarted.
Administrator_@PFA-NAS:~$
|
文档存放位置:/volume1/wiki/docs/...