test

1.以下のパッケージが導入されていること

                                      • -

procmail-3.22-25.1.el6_5.1.x86_64
sendmail-8.14.4-8.el6.x86_64
sendmail-cf-8.14.4-8.el6.noarch

                                      • -

2.sendmail.mc の編集

[root@RHEL61 mail]# diff sendmail.mc sendmail.mc.org
52,53c52,53< TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl< define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl

    • -

> dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
> dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
116c116< dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

    • -

> DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
[root@RHEL61 mail]#


3.local-host-names の編集

自マシンで受信するメールのドメイン名を設定


4.
サービスの再起動

sendmail
saslauthd
※この時点で、mail コマンドの送信が可能


5.

/etc/dovecot/conf.d/10-mail.conf に以下を追加

#メールボックスの位置の指定
mail_location = mbox:~/mail:INBOX=/var/mail/%u

#メールボックスの作成で必要
mail_access_groups=mail


auth_mechanisms = plain login

CUI 環境に GUI 環境を追加

以下を実行する。

# yum groupinstall "Desktop" "Desktop Platform" "General Purpose Desktop"

日本語フォントも必要なので、以下も実行する。

# yum install vlgothic-fonts


※参考情報
http://morrey22.hatenablog.com/entry/2013/04/14/212837
http://reonblog.com/2013/04/07/centos%E3%81%ABgui%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB/

Apache + OpenSSL

1.openssl-perl のインストール

# yum -y install openssl-perl


事前に以下のパッケージを導入しておくこと。

# yum -y install httpd
# yum -y install mod_ssl

CA.pl を利用して設定する場合は以下のパッケージも導入しておくこと。

# yum -y install openssl-perl


1.秘密鍵の作成

# openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
.............++++++
.....++++++
e is 65537 (0x10001)
Enter pass phrase for server.key:★パスフレーズの入力
Verifying - Enter pass phrase for server.key:★上記とパスフレーズの入力
#

※上記は DES/1024 bit で作成
※最近は、genrsa から genpkey に置き換わりつつあるらしい
https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_OpenSSL.html


2.CSR (証明書署名要求) の作成

# openssl req -new -key server.key -out server.csr
Enter pass phrase for server.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:Tokyo
Locality Name (eg, city) [Default City]::Shinagawa-Ku
Organization Name (eg, company) [Default Company Ltd]:★エンターキー
Organizational Unit Name (eg, section) []:★エンターキー
Common Name (eg, your name or your server's hostname) []:192.168.xxx.xxx★実際の接続先を指定
Email Address []:★エンターキー

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:★エンターキー
An optional company name []:★エンターキー
#


3.自署証明書の作成

# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=JP/ST=Tokyo/L=:Shinagawa-Ku/O=Default Company Ltd/CN=192.168.xxx.xxx
Getting Private key
Enter pass phrase for server.key:★「1」のパスフレーズを入力
#


4.秘密鍵からパスフレーズの削除

# cp server.key server.key.org
# openssl rsa -in server.key.org -out server.key
Enter pass phrase for server.key.org:★「1」のパスフレーズを入力
writing RSA key
#

※これをしないと httpd 起動時にパスフレーズを質問される


5./etc/httpd/conf.d/ssl.conf の編集

以下を追加してサービス再起動。

SSLCertificateFile /openssl/server.crt
SSLCertificateKeyFile /openssl/server.key


※おまけ
キーペアの確認は以下の方法で可能
https://cspssl.jp/support/apache/config-keypairs.php#

※参考 URL
http://knowledge.sakura.ad.jp/beginner/2813/
http://www.maruko2.com/mw/Apache/SSL%E8%87%AA%E5%B7%B1%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E4%BD%9C%E6%88%90%E3%81%A8mod_ssl%E3%81%AE%E8%A8%AD%E5%AE%9A
http://lpi.universe-network.net/doku.php?id=wiki:certification:lpic303
http://archive.linux.or.jp/JF/JFdocs/SSL-RedHat-HOWTO-3.html#ss3.1
https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/7/html-single/Security_Guide/index.html
http://dotnsf.blog.jp/archives/3181024.html
http://qiita.com/cs_sonar/items/81b30c7a1d86d729c7fc
http://qiita.com/a_yasui/items/2e81b0fe77e1a62f2272
http://www.aconus.com/~oyaji/centos/apache_ssl_centos.htm

SAMBA の基本的な設定

(1) ユーザの作成

UNIX ユーザの作成。

# useradd test01
# passwd test01
ユーザー test01 のパスワードを変更。
新しいパスワード:
よくないパスワード: 異なる文字が十分に含まれていません
よくないパスワード: 簡単すぎます
新しいパスワードを再入力してください:
passwd: 全ての認証トークンが正しく更新できました。

上記の UNIX ユーザを SAMBA 上のユーザとして作成。

# pdbedit -a -u test01
new password:
retype new password:
Unix username:        test01
NT username:
Account Flags:        [U          ]
User SID:             S-1-5-21-2724919445-2660786417-2727936258-1000
Primary Group SID:    S-1-5-21-2724919445-2660786417-2727936258-513
Full Name:
Home Directory:       \\rhel6\test01
HomeDir Drive:
Logon Script:
Profile Path:         \\rhel6\test01\profile
Domain:               RHEL6
Account desc:
Workstations:
Munged dial:
Logon time:           0
Logoff time:          木, 07  2月 2036 00:06:39 JST
Kickoff time:         木, 07  2月 2036 00:06:39 JST
Password last set:    火, 23  6月 2015 20:49:12 JST
Password can change:  火, 23  6月 2015 20:49:12 JST
Password must change: never
Last bad password   : 0
Bad password count  : 0
Logon hours         : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

以下でユーザの一覧を表示。

# pdbedit -L
test01:500:

http://www.samba.gr.jp/project/translation/3.5/htmldocs/manpages-3/pdbedit.8.html


(2)smb.conf の設定

以下のコマンドで現在の設定を確認する。

# testparm -sv

smb.conf に以下の設定を追加。

[test]
        comment = test
        browseable = yes
        writable = yes
        path = /test

サービスを再起動。

# service smb restart
SMB サービスを停止中:                                      [  OK  ]
SMB サービスを起動中:                                      [  OK  ]
# service nmb restart
NMB サービスを停止中:                                      [  OK  ]
NMB サービスを起動中:                                      [  OK  ]
#

(3) 接続

test01 ユーザで接続。

# smbclient -L localhost -U%
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-14.el6_6]

        Sharename       Type      Comment
        ---------       ----      -------
        test            Disk      test
        IPC$            IPC       IPC Service (Samba Server Version 3.6.23-14.el6_6)
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-14.el6_6]

        Server               Comment
        ---------            -------
        RHEL6                Samba Server Version 3.6.23-14.el6_6

        Workgroup            Master
        ---------            -------
        MYGROUP              RHEL6
# smbclient //127.0.0.1/test -U test01 xxxxxx
                                       ^^^^^^★パスワード
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-14.el6_6]
smb: \> ls
  .                                   D        0  Tue Jun 23 20:55:40 2015
  ..                                 DR        0  Tue Jun 23 20:55:40 2015

                37904 blocks of size 524288. 32104 blocks available
smb: \> help
?              allinfo        altname        archive        blocksize
cancel         case_sensitive cd             chmod          chown
close          del            dir            du             echo
exit           get            getfacl        geteas         hardlink
help           history        iosize         lcd            link
lock           lowercase      ls             l              mask
md             mget           mkdir          more           mput
newer          open           posix          posix_encrypt  posix_open
posix_mkdir    posix_rmdir    posix_unlink   print          prompt
put            pwd            q              queue          quit
readlink       rd             recurse        reget          rename
reput          rm             rmdir          showacls       setea
setmode        stat           symlink        tar            tarmode
timeout        translate      unlock         volume         vuid
wdel           logon          listconnect    showconnect    ..
!
smb: \> quit
#


接続状況を確認。
2 回目の実行結果は、上記の smbclient コマンドで接続済みの状態で実行したもの。

# smbstatus

Samba version 3.6.23-14.el6_6
PID     Username      Group         Machine
-------------------------------------------------------------------

Service      pid     machine       Connected at
-------------------------------------------------------

No locked files

#
# smbstatus

Samba version 3.6.23-14.el6_6
PID     Username      Group         Machine
-------------------------------------------------------------------
2247      test01        test01        rhel6        (127.0.0.1)

Service      pid     machine       Connected at
-------------------------------------------------------
test         2247   rhel6         Tue Jun 23 20:58:00 2015

No locked files

#

https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-File_and_Print_Servers.html
https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/index.html
http://www.samba.gr.jp/doc/
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/tipsindex_samba.html
http://centossrv.com/samba.shtml
http://d.hatena.ne.jp/perlcodesample/20090111/1230798794

FTP コマンドの制御

FTP コマンドは以下のように存在する。

http://www.iana.org/assignments/ftp-commands-extensions/ftp-commands-extensions.xhtml
http://ja.wikipedia.org/wiki/FTP%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E4%B8%80%E8%A6%A7


実行できるコマンドは、/etc/vsftpd/vsftpd.conf の cmds_allowed で制御可能。


以下はデフォルト状態。

# telnet 127.0.0.1 21
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 (vsFTPd 2.2.2)
USER XXXX★ユーザ名
331 Please specify the password.
PASS XXXX★パスワード
230 Login successful.
help
214-The following commands are recognized.
 ABOR ACCT ALLO APPE CDUP CWD  DELE EPRT EPSV FEAT HELP LIST MDTM MKD
 MODE NLST NOOP OPTS PASS PASV PORT PWD  QUIT REIN REST RETR RMD  RNFR
 RNTO SITE SIZE SMNT STAT STOR STOU STRU SYST TYPE USER XCUP XCWD XMKD
 XPWD XRMD
214 Help OK.
stat
211-FTP server status:
     Connected to 127.0.0.1
     Logged in as test01
     TYPE: ASCII
     No session bandwidth limit
     Session timeout in seconds is 300
     Control connection is plain text
     Data connections will be plain text
     At session startup, client count was 1
     vsFTPd 2.2.2 - secure, fast, stable
211 End of status
pwd
257 "/home/xxxx"
quit
221 Goodbye.
Connection closed by foreign host.
#

/etc/vsftpd/vsftpd.conf を以下に設定変更。

cmds_allowed=HELP,STAT

許可したコマンドは実行できる。

# telnet 127.0.0.1 21
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 (vsFTPd 2.2.2)
USER XXXX★ユーザ名
331 Please specify the password.
PASS XXXX★パスワード
230 Login successful.
help
214-The following commands are recognized.
 ABOR ACCT ALLO APPE CDUP CWD  DELE EPRT EPSV FEAT HELP LIST MDTM MKD
 MODE NLST NOOP OPTS PASS PASV PORT PWD  QUIT REIN REST RETR RMD  RNFR
 RNTO SITE SIZE SMNT STAT STOR STOU STRU SYST TYPE USER XCUP XCWD XMKD
 XPWD XRMD
214 Help OK.
stat
211-FTP server status:
     Connected to 127.0.0.1
     Logged in as test01
     TYPE: ASCII
     No session bandwidth limit
     Session timeout in seconds is 300
     Control connection is plain text
     Data connections will be plain text
     At session startup, client count was 1
     vsFTPd 2.2.2 - secure, fast, stable
211 End of status
pwd
550 Permission denied.
quit
550 Permission denied.