1. 程式人生 > >Debian8 Linux上安裝SSH伺服器並配置sshd_config檔案&啟用root ssh登入

Debian8 Linux上安裝SSH伺服器並配置sshd_config檔案&啟用root ssh登入

Debian Linux上安裝SSH伺服器

 

安裝SSH伺服器debian Linux允許我們通過ssh協議登入debian伺服器。SSH是從遠端位置登入debian的首選方法,因為ssh協議通過Internet提供安全的加密連線。

在本教程中我們將學習如何在Debian 8.3上安裝SSH伺服器。

debian 8.3的SSH伺服器由openssh-server軟體包提供。我們可以使用apt-get install命令在debian Linux上安裝openssh-server。

 

在Debian 8上安裝openssh伺服器

 

首先使用apt-get update命令更新apt源列表。

apt-get update

 

然後使用apt-get install命令在debian上安裝openssh伺服器。

apt-get install openssh-server

 

現在啟動並啟用debian ssh伺服器以在系統重啟時啟動。

 

systemctl start ssh.service

systemctl啟用ssh.service

 

還執行netstat命令以確保ssh埠22已開啟並正在執行。

netstat -tulnp | grep 22

安裝SSH伺服器Debian Linux  -  Openssh Server Debian 8.3

 

您可以使用systemctl命令檢視ssh伺服器的狀態。

systemctl status ssh.service

ssh伺服器狀態debian linux

 

在Debian上啟用root ssh登入

 

預設情況下,Debian Linux不允許以root使用者身份通過​​SSH協議登入伺服器。已從主ssh配置檔案中禁用Debian ssh root登入。如果您嘗試以root使用者身份登入,則會收到錯誤訊息“許可權被拒絕,請再試一次”。

出於安全原因,允許SSH root訪問是不好的做法。但是為了你的知識,讓我們看看它是如何完成的。

 

在sshd_config檔案中設定PermitRootLogin yes

 

/ etc / ssh / sshd_config檔案中的PermitRootLogin引數控制ssh root許可權。預設情況下,Debian Linux中PermitRootLogin的值為“without-password”。要允許root登入,我們需要將PermitRootLogin設定為yes。

 

首先使用文字編輯器開啟ssh配置檔案。

vim  /etc/ssh/sshd_config

 

然後將PermitRootLogin的值更改為yes

PermitRootLogin yes

如何啟用Debian root SSH登入 - 在Debian Linux 8中允許root ssh訪問

 

然後儲存ssh配置檔案並使用systemctl命令重新啟動ssh服務

systemctl restart ssh.service

 

現在,您應該能夠通過SSH協議使用root使用者帳戶訪問您的debian伺服器。

預設情況下已禁用debian中的ssh root登入,因為不建議通過ssh使用root密碼。您通常應該做的是以普通Linux使用者身份ssh到伺服器,然後使用su命令以root使用者身份登入。

 

轉載來源:https://www.configserverfirewall.com/debian-linux/install-debian-ssh-server-openssh/

轉載來源:https://www.configserverfirewall.com/debian-linux/enable-debian-root-ssh-login/