前言
稍微記錄一下ssh連接WSL,雖然已經有很多教程了,嘻嘻嘻
先說明一下基本步驟:
- 首先,由于WSL自帶的ssh部件不是很全,所以需要先洗掉后重新安裝
- 之后,修改配置資訊
- 最后,重啟ssh服務
全程只需要三步,挺簡單的,那么正文開始...
正文
1. 卸載重裝ssh服務
sudo apt remove openssh-server
sudo apt install openssh-server
2. 修改配置資訊
(1)修改SSH Server的監聽埠,這里修改為23
sudo sed -i '/Port /c Port 23' /etc/ssh/sshd_config
(2)修改SSH Server的監聽地址
sudo sed -i '/ListenAddress 0.0.0.0/c ListenAddress 0.0.0.0' /etc/ssh/sshd_config
(3)修改SSH Server允許使用用戶名密碼的方式登錄
sudo sed -i '/PasswordAuthentication /c PasswordAuthentication yes' /etc/ssh/sshd_config
(4)修改SSH Server允許遠程root用戶登錄
sudo sed -i '/PermitRootLogin /c PermitRootLogin yes' /etc/ssh/sshd_config
3. 重啟ssh服務
sudo service ssh restart
4. 使用ssh登錄
ssh username@hostname -p 23
在此,username為登錄的用戶名,hostname可為localhost或127.0.0.1或實際的ip地址,
參考資料
知乎
CSDN
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/227677.html
標籤:其他
上一篇:使用ssh連接WSL
