服務器遠程root屏蔽以及登錄端口設定(ssh)

爲了安全考慮,有時候我們希望遠程登錄服務器時,防止使用超級用戶(root)直接進行登錄並且修改ssh默認登錄端口。

修改配置文件: /etc/ssh/sshd_config

修改內容如下所示:

	[root@backgw conf]# cat /etc/ssh/sshd_config 
#	$OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

<span style="color:#ff0000;"><strong>#Port 22
Port 60000          ### 修改默認端口號</strong></span>
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
<strong><span style="color:#ff0000;">PermitRootLogin no     # 禁止使用root用戶登錄系統</span></strong>
#StrictModes yes
……………………
……………………

修改該文件後,重新啓動sshd服務

service sshd restart

 

這樣遠程登錄時,屏蔽root用戶以及使用ssh端口爲60000(設定默認值)。


這樣就可以使用  ssh -p 6000 [email protected] 來登錄服務器。(可以使用telnet xxx.xx.xxx.xxx.xxx  6000 來測試是否可以連接)


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