2013年7月12日金曜日

LinuxのFTPサーバ(vsftpd)にrootで接続

通常FTPでサーバに接続する場合は、root以外のユーザを使用しますが、時にはそれが
めんどくさい、いえ、rootで接続する必要がある場合もあるのでその手順をまとめます。
AWS上のEC2(Amazon Linux)にvsftpdをインストールしてrootで接続する手順です。

【FTPサーバ】
OS: Amazon Linux AMI 2013.03(64-bit)
vsftpd: 2.2.2


■AMIバージョン確認

[ec2-user@ip-10-77-30-93 ~]$ cat /etc/system-release Amazon Linux AMI release 2013.03 [ec2-user@ip-10-77-30-93 ~]$

■rootパスワード設定

[ec2-user@ip-10-77-30-93 ~]$ cat /etc/system-release Amazon Linux AMI release 2013.03 [ec2-user@ip-10-77-30-93 ~]$ sudo passwd Changing password for user root. New password: BAD PASSWORD: it is based on a dictionary word Retype new password: passwd: all authentication tokens updated successfully. [ec2-user@ip-10-77-30-93 ~]$ su - Password: [root@ip-10-77-30-93 ~]#

■vsftpd インストール

[root@ip-10-77-30-93 ~]# yum install vsftpd (中略) ======================================================================= Package Arch Version Repository Size ======================================================================= Installing: vsftpd x86_64 2.2.2-11.9.amzn1 amzn-main 163 k Transaction Summary ======================================================================= Install 1 Package(s) Total download size: 163 k Installed size: 331 k Is this ok [y/N]: y Downloading Packages: vsftpd-2.2.2-11.9.amzn1.x86_64.rpm | 163 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : vsftpd-2.2.2-11.9.amzn1.x86_64 1/1 Verifying : vsftpd-2.2.2-11.9.amzn1.x86_64 1/1 Installed: vsftpd.x86_64 0:2.2.2-11.9.amzn1 Complete! [root@ip-10-77-30-93 ~]#

■バージョン確認

[root@ip-10-77-30-93 ~]# vsftpd -v vsftpd: version 2.2.2 [root@ip-10-77-30-93 ~]#

■vsftpd.confのuserlist_enable=YESとなっていることを確認

[root@ctc-dev-cms ~]# grep -n userlist_enable /etc/vsftpd/vsftpd.conf 118:userlist_enable=YES [root@ctc-dev-cms ~]#

■user_listのrootをコメントアウト

[root@ctc-dev-cms ~]# cp -p /etc/vsftpd/user_list /etc/vsftpd/user_list.org [root@ctc-dev-cms ~]# vi /etc/vsftpd/user_list [root@ctc-dev-cms ~]# diff /etc/vsftpd/user_list /etc/vsftpd/user_list.org 7c7 < #root --- > root [root@ctc-dev-cms ~]#

■ftpusersのrootをコメントアウト

[root@ctc-dev-cms ~]# cp -p /etc/vsftpd/ftpusers /etc/vsftpd/ftpusers.org [root@ctc-dev-cms ~]# vi /etc/vsftpd/ftpusers [root@ctc-dev-cms ~]# diff /etc/vsftpd/ftpusers /etc/vsftpd/ftpusers.org 2c2 < #root --- > root [root@ctc-dev-cms ~]#

■vsftpd起動(再起動)

[root@ip-10-77-30-93 ~]# /etc/init.d/vsftpd start Starting vsftpd for vsftpd: [ OK ] [root@ip-10-77-30-93 ~]#

■FFFTPで接続

※FFFTPの設定で 接続 > 拡張 > 「PASVモードを使う(V)」のチェックを外すところがポイント。



rootでのFTP接続成功!!

こちらの情報が何かのお役に立ちましたら幸いです。 m(_ _)m

2013年4月6日土曜日

Webmin ログイン画面のカスタマイズ


Webmin標準のログイン画面のメッセージの変更やIPアドレスを非表示にする手順をまとめます。

OS: CentOS 6.4(64-bit)
Webmin: 1.620


■ログイン画面のメッセージを変更
[root@centos64 ~]# cd /usr/libexec/webmin/lang [root@centos64 lang]# cp -p en en.org [root@centos64 lang]# vi en [root@centos64 lang]# diff en en.org 131,132c131,132 < session_header=Login to Change Password < session_mesg=You must enter a username and password to login to the Webmin server. --- > session_header=Login to Webmin > session_mesg=You must enter a username and password to login to the Webmin server on $1. [root@centos64 lang]#
131行目のsession_headerの値および132行目のsession_mesgの値を修正。

■ログイン画面のボックスのサイズ変更し、リンク追加
[root@centos64 ~]# cd /usr/libexec/webmin/ [root@centos64 webmin]# cp -p session_login.cgi session_login.cgi.org [root@centos64 webmin]# vi session_login.cgi [root@centos64 webmin]# diff session_login.cgi session_login.cgi.org 62c62 < "width=60% class='loginform'", 2); --- > "width=40% class='loginform'", 2); 91,92d90 < print "<br /><a href=\"https://54.249.xxx.xxx:81/re-issued_password.html\" target=\"_blank\">"; < print "<b>Forgot your password?</b></a><br />\n"; [root@centos64 webmin]# [root@centos64 webmin]# head -93 session_login.cgi | tail -4 print &ui_form_end(); print "<br /><a href=\"https://54.249.xxx.xxx:81/re-issued_password.html\" target=\"_blank\">"; print "<b>Forgot your password?</b></a><br />\n"; print "</center>\n"; [root@centos64 webmin]#
リンクの追加は、&ui_form_end()と</center>の間が適当です。
※表示の都合上、一部”<”と”>”に置き換えています。



■ログイン画面確認

Webminの再起動等は不要で変更が即時反映されます。

以上です。何かのお役にたてれば幸いです。

2013年3月29日金曜日

Webminを利用してブラウザからユーザパスワード変更


Webminを利用すればLinuxのOSユーザのパスワードをブラウザから変更することが
可能ですが、それ以外の操作はさせたくない場合の設定方法をまとめます。

OS: CentOS 6.4(64-bit)
Webmin: 1.620


■ユーザ作成
あらかじめOSユーザを作成しておく必要があります。
※OSユーザ一括生成はこちらを参照。
今回はuseraddコマンドでユーザ作成します。
[root@centos64 ~]# groupadd -g 600 public [root@centos64 ~]# useradd -g 600 -u 6001 user01 [root@centos64 ~]# useradd -g 600 -u 6002 user02 [root@centos64 ~]# passwd user01 [root@centos64 ~]# passwd user02

■設定概要
1) ブラウザよりWebminにrootログイン 2) Webminユーザを作成 3) Webminユーザの編集でパスワードの変更のアクセス制御オプションを設定 4) 作成したユーザでログインしてパスワードの変更確認

■Webminユーザ作成
Webmin → Webminユーザ → 新しいWebminユーザを作成


■Webminユーザの作成
「user01」を作成する。

※変更箇所のみ
▼Webminユーザのアクセス権
 ユーザ名: OSで作成したユーザ
 パスワード: Unix認証
 本名: 適当に
▼ユーザインターフェイス設定
 言語: Japanese(JA_JP.UTF-8)
 パーソナルテーマ: MSC.LinuxTheme
▼使用可能な Webmin モジュール
 パスワードの変更にチェック(それ以外はチェックしない)

作成ボタンクリック

■Webminユーザ

↑作成したユーザ(user01)をクリック

■Webminユーザの編集

↑パスワードの変更をクリック

■モジュールのアクセス制御

パスワードの変更のアクセス制御オプション(変更箇所のみ)
 Users whose passwords can be changed: Only this user
 Can force users to change password at next login?: いいえ
 Change password in other modules?: いいえ

保存ボタンをクリック

■Webminユーザの編集

▼Permissions for all modules(変更箇所のみ)
 ファイル選択の root ディレクトリ: User's home directory
 Can send feedback email?: No
 Grant new module permissions to user?: いいえ
 Show Webmin search field?: いいえ

保存ボタンをクリック
その後ログアウト


■作成したユーザでログイン

ここのメッセージを変更することも可能です。IPアドレスとか表示させたくない場合も
考えられますし・・・。設定方法は後日まとめます。

■パスワードの変更



これで画面上からOSユーザのパスワードの変更ができています。

以上です。
前半の設定になりますが、ユーザインタフェイス設定のパーソナルテーマに
MSC.LinuxThemeを選択するところがポイントでしょうか。
画面イメージが変わりますが、システム情報が表示される画面を無くすことができます。

何かのお役にたてれば幸いです。

2013年3月23日土曜日

Webminのセキュリティ対策 SSL化とポート番号変更


WebminはWebブラウザからほぼすべてのOS設定が可能なため、アクセス等のセキュリティ対策
が重要です。少なくともデフォルトポートを変更し、SSL化してhttpsでの接続を推奨します。
そのための手順をまとめます。

OS: CentOS 6.3(64-bit)
Webmin: 1.620


■SSLインストール
[root@centos64 ~]# yum -y install mod_ssl openssl ======================================================================== Package Arch Version Repository Size ======================================================================== Installing: mod_ssl x86_64 1:2.2.15-26.el6.centos base 90 k Updating: openssl x86_64 1.0.0-27.el6_4.2 updates 1.4 M Transaction Summary ======================================================================== Install 1 Package(s) Upgrade 1 Package(s) (以下省略) [root@centos64 ~]# [root@centos64 ~]# /etc/init.d/httpd restart
SSLを有効化するためにhttpdを再起動。

■Net::SSLeayインストール
ブラウザでWebminにログイン
左側メニューの、Webmin → Webmin設定 → SSL暗号化


download and installのリンクからNet::SSLeayをインストール


再びSSL暗号化画面にてSSLを使用可能にする。


SSLが使用可能になるとhttpでのアクセスは拒否されるようだ。

Webブラウザでアクセスすると https://192.168.77.148:10000/ でログイン画面が表示される。




■デフォルトのポート番号を変更
[root@centos64 ~]# cd /etc/webmin/ [root@centos64 webmin]# cp -p miniserv.conf miniserv.conf.org [root@centos64 webmin]# vi miniserv.conf [root@centos64 webmin]# diff miniserv.conf miniserv.conf.org 1c1 < port=4649 --- > port=10000 16c16 < listen=4649 --- > listen=10000 [root@centos64 webmin]#
1行目と16行目を修正。ポート番号を10000から4649に変更。
その後Webminを再起動
[root@centos64 webmin]# /etc/init.d/webmin restart Stopping Webmin server in /usr/libexec/webmin Starting Webmin server in /usr/libexec/webmin Pre-loaded WebminCore [root@centos64 webmin]#

Webブラウザで https://192.168.77.148:4649/ にアクセスするとログイン画面が表示される。


以上です。何かのお役に立てれば幸いです。

2013年3月22日金曜日

CentOS 6.4にWebminインストール


WebminはUnix系OSのシステム管理用のWebベースのインターフェイスです。
Webブラウザを使用して、ユーザアカウント、Apache、DNS、ファイル共有等を
セットアップすることができます。
※ http://www.webmin.com/ の What is Webmin? を直訳しただけです。

OS: CentOS 6.3(64-bit)
Webmin: 1.620


■リポジトリ設定(webminはデフォルトリポジトリに登録されていないので)
[root@centos64 ~]# vi /etc/yum.repos.d/webmin.repo [root@centos64 ~]# cat /etc/yum.repos.d/webmin.repo [webmin] name=Webmin Distribution Neutral mirrorlist=http://download.webmin.com/download/yum/mirrorlist enabled=0 [root@centos64 ~]#

■jcameron-key.ascのインポート
[root@centos64 ~]# wget http://www.webmin.com/jcameron-key.asc [root@centos64 ~]# ll jcameron-key.asc -rw-r--r-- 1 root root 1320 12月 5 09:58 2002 jcameron-key.asc [root@centos64 ~]# rpm --import jcameron-key.asc [root@centos64 ~]#

■yumでインストール
[root@centos64 ~]# yum --enablerepo=webmin -y install webmin ======================================================================== Package Arch Version Repository Size ======================================================================== Installing: webmin noarch 1.620-1 webmin 21 M Transaction Summary ======================================================================== Install 1 Package(s) Total download size: 21 M (以下省略) [root@centos64 ~]#

■※インストール直後は起動している。
[root@centos64 ~]# /etc/init.d/webmin status Webmin (pid 3030) is running [root@centos64 ~]#



■ブラウザでアクセス
※httpdを起動させておく必要がある。
http://192.168.77.148:10000/
Username: root
Password: rootのパスワード

■日本語表示設定
左側メニューの、Webmin → Change Language and Theme
Webmin UI Language を Japanese (JA_JP.UTF-8)に変更してMake Changesボタンをクリック。


以上です。何かのお役に立てれば幸いです。