動作確認 [ FC1 / FC2 / FC3 / FC4 / FC5 / FC6 / Fedora7 / Fedora8 / CentOS4 / CentOS5 ]
サーバが直接外部とつながっている場合は、特に確認下さい。
不要ポートが開いていればいる程、危険性が増します。
# yum -y install nmap
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for nmap to pack into transaction set.
nmap-4.11-1.1.i386.rpm 100% |=========================| 9.8 kB 00:00
---> Package nmap.i386 2:4.11-1.1 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
nmap i386 2:4.11-1.1 core 671 k
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 671 k
Downloading Packages:
(1/1): nmap-4.11-1.1.i386 100% |=========================| 671 kB 00:01
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: nmap ######################### [1/1]
Installed: nmap.i386 2:4.11-1.1
Complete!
ポート状況確認
# nmap localhost
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2007-02-19 23:23 JST
Interesting ports on localhost.localdomain (127.0.0.1):
Not shown: 1679 closed ports
PORT STATE SERVICE
22/tcp open ssh
Nmap finished: 1 IP address (1 host up) scanned in 0.401 seconds
|
ターミナルをsshに暗号化したからといって十分ではありません。何せ通信内容が暗号化されただけですから・・・
当URLで紹介している
SSHサーバの構築(OpenSSH)で、まず、基本セキュアを実施してください。(rootでログオンさせない等・・)
以下の設定を行なうことにより、接続元のネットワークを限定する事が出来ます。
サーバへsshログオンを許可するネットワークの指定
# vi /etc/hosts.allow
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
sshd: 192.168.1.
サーバへsshログオンを遮断するネットワークの指定
# vi /etc/hosts.deny
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
sshd: ALL
|
以下の設定を行なうことにより、ログオンユーザを限定する事が出来ます。上記と組み合わせる事により、ネットワーク内の限定ユーザのみログオン可という様に強化する事が出来ます。
サーバへsshログオンを許可するユーザの指定
# vi /etc/pam.d/sshd
%PAM-1.0
auth required pam_stack.so service=system-auth
auth required pam_nologin.so
account required pam_stack.so service=system-auth
password required pam_stack.so service=system-auth
session required pam_selinux.so
session required pam_stack.so service=system-auth
session required pam_limits.so
session optional pam_console.so
最終行に以下を追加
account required pam_access.so
# vi /etc/security/access.conf
# Login access control table.
#
:
:
#
# The second field should be a list of one or more login names, group
最終行に以下を追加
-:ALL EXCEPT wheel linux:ALL
|
root のパスワードを知っていれば誰でもroot(管理者)になることができてしまいます。
以下の設定を行なうことにより、一般ユーザからroot(管理者)になれるユーザを限定する事が可能になります。(suコマンドの制限)
サーバへsshログオンを許可するユーザの指定
# vi /etc/login.defs
最終行に以下を追加
SU_WHEEL_ONLY yes
# vi /etc/pam.d/su
#%PAM-1.0
auth sufficient /lib/security/$ISA/pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient /lib/security/$ISA/pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
コメントを外す
auth required /lib/security/$ISA/pam_wheel.so use_uid
auth required /lib/security/$ISA/pam_stack.so service=system-auth
account required /lib/security/$ISA/pam_stack.so service=system-auth
password required /lib/security/$ISA/pam_stack.so service=system-auth
session required /lib/security/$ISA/pam_stack.so service=system-auth
session optional /lib/security/$ISA/pam_selinux.so multiple
session optional /lib/security/$ISA/pam_xauth.so
ユーザ"linux"のセカンダリグループに"wheel"を追加
# usermod -G wheel linux
|
メールの送受信は行ないたいが、サーバログインはさせたくない場合があると思います。
以下の設定を行なうことによりログインシェルを無効にさせてログインさせなくする事が出来ます。
新規にユーザを作成する場合
# useradd -s /bin/false <ユーザ名>
既に存在しているユーザに設定する場合
# usermod -s /bin/false <ユーザ名>
|