通過xshell遠程連接ubuntu


ubuntu開啟sshd服務
SSH分客戶端openssh-client和openssh-server
如果你只是想登陸別的機器的SSH只需要安裝openssh-client(ubuntu有默認安裝,如果沒有則sudo apt-get install openssh-client),如果要使本機開放SSH服務就需要安裝openssh-server
sudo apt-get install openssh-server
然后確認sshserver是否啟動了:
ps -e |grep ssh
如果看到sshd那說明ssh-server已經啟動了。
如果沒有則可以這樣啟動:sudo /etc/init.d/ssh start
ssh-server配置文件位於/ etc/ssh/sshd_config,在這里可以定義SSH的服務端口,默認端口是22,你可以自己定義成其他端口號,如222。
然后重啟SSH服務:
sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start
然后使用以下方式登陸SSH:
ssh tuns@192.168.0.100 tuns為192.168.0.100機器上的用戶,需要輸入密碼。
斷開連接:exit


連接不上的問題

1、在虛擬機終端使用root帳號登錄,編輯/etc/ssh/sshd_config文件

gedit /etc/ssh/sshd_config
2、找到Authentication配置部分,將PermitRootLogin without-password修改為PermitRootLogin yes,然后保存。

# Authentication:
LoginGraceTime 120
#PermitRootLogin without-password
PermitRootLogin yes
StrictModes yes
PasswordAuthentication yes
PermitEmptyPasswords no

說明:sshd_config是ssh的配置文件,其中有一個選項 PermitRootLogin 用來配置是否允許root用戶登錄,默認的without-password表示不允許使用密碼進行全登錄認證,yes則是允許root登錄。

3、重啟ssh服務,既可以通過Xshell正常連接服務器


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM