Adding SSH keys to EdgeOS-based devices like Ubiquiti Edge Router X
Add this to your local .ssh config to make your life easier:
Host erx
HostName YOUR_EDGE_ROUTER_X_IP
User YOUR_ERX_ADMIN_USERNAME
Now let's add your ssh public key:
> cat ~/.ssh/id_*pub
ssh-ed25519 PURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR kitten
# Pick your fave key
> ssh erx
Enter password: # for the very last time!
foobie@ubnt:~$ configure
[edit]
foobie@ubnt# set system login user foobie authentication public-keys kitten type ssh-ed25519
[edit]
foobie@ubnt# set system login user foobie authentication public-keys kitten key PURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
[edit]
foobie@ubnt# commit
[edit]
foobie@ubnt# save
Saving configuration to '/config/config.boot'...
Done
[edit]
foobie@ubnt# cat .ssh/authorized_keys
# Automatically generated by Vyatta configuration
# Do not edit, all changes will be lost
ssh-ed25519 PURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR kitten
[edit]
foobie@ubnt# exit
exit
foobie@ubnt:~$ exit
logout
> ssh erx
foobie@ubnt:~$ # SUCCESS!
你需要在執行
commit 之前,為 foobie 帳號設定一個密碼。請依序執行以下指令:- 設定純文字密碼:
set system login user foobie authentication plaintext-password "你的密碼"
- 進階建議:若想完全停用密碼登入
如果你希望達成「只能用 Key 登入,不能用密碼登入」的安全性,請在上述
commit 成功後,額外執行:set service ssh disable-password-authentication
commit
save
Cribbed from the VyOS ssh docs.
Note: you should be sure you have a backup of the config with password auth enabled before doing this, else it's a full factory reset if you lose all the keys that let you log in.
> ssh erx
# No password to type ... feels so good!
foobie@ubnt:~$ configure
[edit]
foobie@ubnt# show service ssh
port 22
protocol-version v2
[edit]
foobie@ubnt# set service ssh disable-password-authentication
[edit]
admin@ubnt# show service ssh
disable-password-authentication
port 22
protocol-version v2
[edit]
foobie@ubnt# commit
[edit]
foobie@ubnt# save
Saving configuration to '/config/config.boot'...
Done
[edit]
foobie@ubnt# exit
exit
foobie@ubnt:~$ exit
logout
yxbinghe
NFS / SMB 網絡掛載(遠端擴展)
如果你需要放很大的檔案(例如抓封包、跑大型日誌),可以掛載 NAS 或電腦的硬碟。
指令範例:
bash
sudo mount -t nfs 192.168.1.100:/share /mnt/nfs
/opt/vyatta/config 的指向
在你提供的 df -h 最後一行:
none 123.6M 360.0K 123.3M 0% /opt/vyatta/config
這顯示了 Vyatta 配置系統的掛載點。在 EdgeOS 中,為了確保使用者的自定義腳本(如 VPN 憑證、frp 執行檔、DDNS 腳本)能在升級後存活,官方預留了兩個特定路徑:
/config/:用於存放持久化檔案。
/config/scripts/post-config.d/:用於存放開機啟動腳本。