ubuntu/linux ssh

安裝ssh服務

sudo apt-get install openssh-server

檢查服務是否啓動

ps -e | grep ssh

啓動服務

/etc/init.d/ssh start
/etc/init.d/ssh restart

sshd服務基本配置

基於密鑰認證的服務端基本安全設置:
1、修改/etc/ssh/sshd_config,具體如下:
Protocol 2 #只支持SSH2協議

Port <端口號> #修改默認端口號
MaxStartups 5 #同時允許5個尚未登錄的SSH聯機
MaxAuthTries 3   #最大登錄嘗試次數爲3

GSSAPIAuthentication no  #關閉GSSAPI認證
ServerKeyBits 1024  #將ServerKey強度改爲1024比特
PermitEmptyPasswords no  #禁止空密碼進行登錄
ChallengeResponseAuthentication no #禁用s/key密碼
UsePAM no #不通過PAM驗證
PermitRootLogin no #禁止root遠程登錄
PasswordAuthentication no  #不允許密碼方式的登錄
RSAAuthentication no #不允許RSA認證,只針對SSH1
PubkeyAuthentication yes #允許公鑰認證
AuthorizedKeysFile .ssh/authorized_keys #保存公鑰的認證文件
UsePrivilegeSeparation yes #用戶權限設置

SyslogFacility AUTH #記錄SSH登錄情況
LogLevel INFO #記錄等級爲INFO

PrintMotd yes #登錄成功後顯示/etc/motd 文件的內容
PrintLastLog no #不顯示上次登錄信息
Compression yes #是否壓縮命令
KeepAlive yes #防止死連接
StrictModes yes #接受連接請求前對用戶主目錄和相關的配置文件進行宿主和權限檢查
UseDNS no #不使用DNS反解

AllowUsers <用戶名> #允許通過遠程訪問的用戶,多個用戶以空格分隔
AllowGroups <組名> #允許通過遠程訪問的組,多個組以空格分隔
DenyUsers <用戶名> #禁止通過遠程訪問的用戶,多個用戶以空格分隔
DenyGroups <組名> #禁止通過遠程訪問的組,多個組以空格分隔

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