sshサーバ構成
12640 ワード
基本的に、すべてのsshdサーバの詳細設定は/etc/ssh/sshd_に設定されます.configの中!ただし、Linux distributionごとにプリセット設定が異なるので、設定値全体の意味を理解する必要があります!また、プリセットのファイル内では、プリセットが出現してコメントされている設定値(設定値の前に#を付ける)であれば『デフォルト値!』となり、それに基づいて修正してもいいですよ.
プリセットのsshdサービスはもう安全ですが、まだ足りません.(1)rootのログイン権限を取り消すことをお勧めします.(2)sshバージョンを2に設定する.他の設定値は自分の好みで設定してください.通常は勝手な修正はお勧めしません!また、上記のファイル(/etc/ssh/ssh/sshd_config)を変更した場合は、sshdというdaemonを再起動する必要があります.つまり、
[root@www ~]# vim /etc/ssh/sshd_config
# 1. SSH Server , port ,
# Port 22
# SSH 22 port, port, port !
# sshd 22 443 , :『 Port 443 』
# sshd ! , port number !
Protocol 2
# SSH , 1 2 ,CentOS 5.x V2。
# V1 , 『 Protocol 2,1 』 。
# ListenAddress 0.0.0.0
# ! , IP, 192.168.1.100
# 192.168.100.254, 192.168.1.100 sshd , :
# 『 ListenAddress 192.168.1.100 』 SSH
# PidFile /var/run/sshd.pid
# SSHD PID !
# LoginGraceTime 2m
# SSH server , , ,
# SSH server ! !
# Compression delayed
# 。 yes, no (delayed)
# 2. Private Key , !
# HostKey /etc/ssh/ssh_host_key # SSH version 1
# HostKey /etc/ssh/ssh_host_rsa_key # SSH version 2 RSA
# HostKey /etc/ssh/ssh_host_dsa_key # SSH version 2 DSA
# SSH , Host Key ~
# 3. daemon !
SyslogFacility AUTHPRIV
# SSH ,SSH , daemon name
# ? AUTH , /var/log/secure ! ? !
# Linux 。 daemon name :DAEMON,USER,AUTH,
# LOCAL0,LOCAL1,LOCAL2,LOCAL3,LOCAL4,LOCAL5,
# LogLevel INFO
# ! ! ! , !
# 4. ! !
# 4.1
# PermitRootLogin yes
# root ! , no!
# StrictModes yes
# sshd ,
# , 。
# ~.ssh/ ,
# PubkeyAuthentication yes
# AuthorizedKeysFile .ssh/authorized_keys
# , version 2。
# .ssh/authorized_keys
PasswordAuthentication yes
# ! yes !
# PermitEmptyPasswords no
# yes , no ,
# ! !
# 4.2
# RhostsAuthentication no
# .rhosts, .rhosts , no
# IgnoreRhosts yes
# ~/.ssh/.rhosts ! !
# RhostsRSAAuthentication no #
# version 1 , rhosts /etc/hosts.equiv
# RSA ! !
# HostbasedAuthentication no
# , version 2 !
# IgnoreUserKnownHosts no
# ~/.ssh/known_hosts ?
# , no !
ChallengeResponseAuthentication no
# ! , login.conf , !
# PAM , no !
UsePAM yes
# PAM , 。
# UsePAM ChallengeResponseAuthentication no
# 4.3 Kerberos ! Kerberos , !
# KerberosAuthentication no
# KerberosOrLocalPasswd yes
# KerberosTicketCleanup yes
# KerberosTgtPassing no
# 4.4 X-Window !
X11Forwarding yes
# X11DisplayOffset 10
# X11UseLocalhost yes
# X11Forwarding , ssh !
# ssh 。
# 4.5 :
# PrintMotd yes
# ? 、 , yes
# /etc/motd 。 , , no !
# PrintLastLog yes
# ! ! yes !
# TCPKeepAlive yes
# , TCP 。
# , , !
# , ,SSH ! !
# , no !
UsePrivilegeSeparation yes
# 。 sshd port 22 ,
# root 。 student ,
# sshd sutdent sshd ,
MaxStartups 10
# ? SSH , ,
# ! , ,
# , ,
# 4.6 :
DenyUsers *
# , , !
# , ! !
DenyUsers test
DenyGroups test
# DenyUsers ! !
# 5. SFTP !
Subsystem sftp /usr/lib/ssh/sftp-server
# UseDNS yes
# , , DNS
# , no 。
プリセットのsshdサービスはもう安全ですが、まだ足りません.(1)rootのログイン権限を取り消すことをお勧めします.(2)sshバージョンを2に設定する.他の設定値は自分の好みで設定してください.通常は勝手な修正はお勧めしません!また、上記のファイル(/etc/ssh/ssh/sshd_config)を変更した場合は、sshdというdaemonを再起動する必要があります.つまり、
/etc/init.d/sshd restart