前言
SSH (Secure Shell) 讓你可以從遠端安全地連線到伺服器。以下是在 Ubuntu 上安裝 SSH Server 的步驟。
安裝步驟
1. 更新套件列表
sudo apt update
2. 安裝 OpenSSH Server
sudo apt install openssh-server -y
3. 確認服務狀態
sudo systemctl status ssh
應該會看到 active (running)。
4. 設定開機自動啟動
sudo systemctl enable ssh
防火牆設定
如果你有開啟 UFW 防火牆,記得允許 SSH 連線:
sudo ufw allow ssh
sudo ufw status
測試連線
從另一台電腦測試:
ssh 使用者名稱@伺服器IP
例如:
ssh mk@192.168.89.168
常用指令
# 啟動 SSH
sudo systemctl start ssh
# 停止 SSH
sudo systemctl stop ssh
# 重啟 SSH
sudo systemctl restart ssh
# 查看狀態
sudo systemctl status ssh
發佈留言