安裝環境
SSH Server: Ubuntu 22.04
SSH Client: Windows 11
安裝 SSH Server
| 1
 | sudo apt install openssh-server
 | 
設定使用密碼登入
使用 vi 開啟 sshd_config
| 1
 | sudo vi /etc/ssh/sshd_config
 | 
修改伺服器 sshd_config
| 1
 | PasswordAuthentication yes
 | 
vi 離開文件方法
先按 Esc
- :q: 沒有做修改離開
- :wq: 保存並離開
- :q!: 不保存就離開
重新啟動 SSH 伺服器
取得伺服器 IP
使用 ifconfig 查看 IP
若沒安裝時使用以下指令安裝
| 12
 
 | sudo apt updatesudo apt install net-tools
 
 | 
設定免密碼登入
客戶端產生 SSH Key
從 Client 複製 public key 到 Server
| 12
 
 | cd %USERPROFILE%\.sshscp id_rsa.pub SERVER_USERNAME@SERVER_HOST:~/.ssh
 
 | 
伺服器端設定 SSH Key
| 12
 
 | cd ~/.sshcat id_rsa.pub >> authorized_keys
 
 | 
修改伺服器 sshd_config
| 12
 
 | PubkeyAuthentication yesPasswordAuthentication no
 
 | 
重新啟動 SSH 伺服器