1. 程式人生 > >Debian Linux安裝OpenSSH(sshd-server)

Debian Linux安裝OpenSSH(sshd-server)

Debian Linux安裝OpenSSH(sshd-server)

 

您需要使用apt-get或aptitude命令在Debian Linux下安裝OpenSSH伺服器。

開啟終端並鍵入以下命令以root使用者身份更新包資料庫:

# apt-get update

 

任務:在Debian Linux下安裝OpenSSH伺服器

鍵入以下命令:

# apt-get install openssh-server

...

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  ssh-askpass rssh molly-guard ufw
The following NEW packages will be installed:
  openssh-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 318 kB of archives.
After this operation, 717 kB of additional disk space will be used.
Get:1 http://mirror.anl.gov/debian/ squeeze/main openssh-server amd64 1:5.5p1-6+squeeze1 [318 kB]
Fetched 318 kB in 3s (89.0 kB/s)         
Preconfiguring packages ...
Selecting previously deselected package openssh-server.
(Reading database ... 153448 files and directories currently installed.)
Unpacking openssh-server (from .../openssh-server_1%3a5.5p1-6+squeeze1_amd64.deb) ...
Processing triggers for man-db ...
Setting up openssh-server (1:5.5p1-6+squeeze1) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Restarting OpenBSD Secure Shell server: sshd.

 

預設情況下,openssh將在TCP埠22上執行。您可以使用以下命令對其進行驗證:示例輸出:
 

# netstat -tulpn | grep :22

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3946 / sshd        
tcp6 0 0 ::: 22 ::: * LISTEN 3946 / sshd     

 

您可以連線到Openssh伺服器,鍵入:

$ ssh [email protected]
$ ssh [email protected]

 

如何在Debian Linux下啟動/停止/重啟OpenSSH伺服器?

以root使用者身份鍵入以下命令:OR 示例會話:

# service ssh stop
# service ssh start
# service ssh restart
# service ssh status

# /etc/init.d/ssh stop
# /etc/init.d/ssh start
# /etc/init.d/ssh restart
# /etc/init.d/ssh status

 

 

如何在防火牆級別開啟埠22?

 

編輯防火牆指令碼並附加以下規則以限制對192.168.1.0/24的訪問:

/sbin/iptables -A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 22 -j ACCEPT

儲存並關閉檔案。或者,您可以按如下方式鍵入命令並將其儲存到防火牆配置檔案中:

#/sbin/iptables -A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 22 -j ACCEPT 
#iptables-save > /path/to/your.firewall.conf

 

如何在Debian Linux下配置和保護OpenSSH伺服器?

您需要使用文字編輯器(如vi,run)編輯/ etc / ssh / sshd_config檔案:

# vi /etc/ssh/sshd_config


請參閱此文章解釋配置選項以進行調整以提高OpenSSH伺服器安全性。

翻譯來源:https://www.cyberciti.biz/faq/debian-linux-install-openssh-sshd-server/