SecureCRT 連接Win10內置ubuntu問題層層突圍

1、安裝windows10內置的linux子系統(windows10 2004版本據說有linux內核)
運行->appwiz.cpl->啓用或關閉windows功能->勾選適用於linux的windows子系統
後面就按照提示下載相應的ubuntu包就可以。
在cmd或powershell命令窗口中輸入bash或wsl就可以進入ubuntu系統,如果你windows使用的管理員權限登錄,進去後是root身份。
在這裏插入圖片描述
ifconfig -a查看了下ip 其實就是自己本機的ip嘛,那就用securecrt去連下,以方便使用。
2、輸入hostname, username 後連接提示: ubuntu The remote system refused the connection.

因爲沒有安裝或啓動 ssh. 使用命令 su root 切換至root用戶. 使用命令 ps -e | grep ssh 查看是否啓動 ssh.

如沒有返回 則嘗試使用命令 sudo apt install openssh-server 嘗試安裝ssh.

如提示已安裝, 使用命令 /etc/init.d/ssh start 啓動ssh服務. 再次嘗試連接

//相關命令 停止服務/etc/init.d/ssh stop 重啓服務/etc/init.d/ssh restart

3、could not load host key.
查了下大概是因爲鑑證證書的問題 使用命令 ssh-keygen -A 生成key

4、a public key file has not been specified for this session would you like to specify one now
在SecureCRT sessions > properties > Connection > SSH2 取消勾選 PublicKey.
在這裏插入圖片描述
5、Reason: Unable to authenticate using any of the configured authentication methods.
修改sshd_config配置信息 vim /etc/ssh/sshd_config 配置項 PasswordAuthentication 值no改爲yes 修改後 使用命令 /etc/init.d/ssh restart 重啓ssh服務.
6、The server has disconnected with an error. Server message reads: A protocol error occurred. Change of username or service not allowed: (root,ssh-connection) -> (xxxxxx,ssh-connection)
因爲SecureCRT設置的用戶名和登錄時輸入的用戶名不一致,在SecureCRT sessions > properties > Connection > SSH2 username 修改一致即可.
或者用securecrt重新創建個連接。
7、如果還是連接不上,仍然報用戶名和密碼錯誤:Password authentication failed.Please verify that the username and password are correct.

vim /etc/ssh/sshd_config

1)、找到# port 22所在的那一行,複製該行內容並修改。

將“#port 22”修改爲“port 22”(將前面的“#”去掉)。

該行內容爲設置SSHd服務的端口號

2)、找到#PermitRootLogin prohibit-password那一行,複製該行內容並修改。

將“#PermitRootLogin prohibit-password”修改爲“PermitRootLogin yes”

改行內容爲設置允許root用戶遠程登錄。

最後停止服務/etc/init.d/ssh stop 重啓服務/etc/init.d/ssh restart

安全提示:當你這樣設置後,你的電腦就面臨着安全風險,windows系統中的超級管理員有各種組策略限制遠程登錄。而使用linux子系統的root遠程登錄一定要謹慎。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章