ラベル UNIX の投稿を表示しています。 すべての投稿を表示
ラベル UNIX の投稿を表示しています。 すべての投稿を表示

2012年8月12日日曜日

[MySQL]インストール後に最初に行うこと

■概要 公開サービスでのMySQL利用を想定している場合、MySQLのインストール後のセキュリティ設定は不適切です。 セキュリティを強化するための設定は、個別に行うことも可能ですが、「mysql_secure_installation」コマンドを利用すると、より簡便に設定可能です。

 ■mysql_secure_installationの実行 

mysql_secure_installationを実行すると以下の設定変更が可能です。

  1. rootパスワードの設定 
  2. rootユーザによるリモートアクセスの禁止 
  3. 匿名(anonymous)ユーザの削除 
  4. デフォルトで作成されているtestデータベースの削除
bash-3.2$ mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] Y ->初期パスワードなし
New password:         ->rootパスワードを変更するため[Y]を入力
Re-enter new password:     ->rootパスワードを変更するため[Y]を再入力
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y ->匿名ユーザを削除するため[Y]を入力
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y ->rootユーザのリモートアクセスを禁止するため[Y]を入力
 ... Success!
By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y ->testデータベースを削除するため[Y]を入力
 - Dropping test database...
ERROR 1010 (HY000) at line 1: Error dropping database (can't rmdir './test/', errno: 17)
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y ->新しい設定を即時反映するため[Y]を入力
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!



以上です。

2011年7月18日月曜日

[Windows][Cygwin]新規ユーザを追加する

■概要
Cygwinではuseradd(UNIXでのユーザ追加コマンド)が存在しません。

■ユーザ登録
ユーザの追加はWindowsのユーザを/etc/passwdファイルに追記します。
mkpasswd -l -u UserName >> /etc/passwd

以上です。

2011年7月10日日曜日

[Linux][CentOS]新規ユーザを追加する

■概要
Linuxで新しくサーバを構築する際に、必ず実行する手順であるユーザの追加方法を
まとめます。

以下CentOSで作業しますが、bashが使える環境であれば同様のコマンドを
使用できます。

■ユーザ登録
セキュリティ上、rootユーザは使用しないポリシーとし、
新規ユーザに適切なsudo権限を付与する運用がベターです。

・新規ユーザ用グループを作成

※rootユーザで作業する

# groupadd appmng

・新規ユーザ作成
# useradd -g appmng appmng
# ls -l /home/
合計 4
drwx------ 2 appmng appmng 4096  7月  1 15:28 2011 appmng
⇒作成されていること

・新規ユーザのパスワードを変更する
# passwd appmng
ユーザー appmng のパスワードを変更。
新しいパスワード:
新しいパスワードを再入力してください:
passwd: 全ての認証トークンが正しく更新できました。

・新規ユーザにsudo権限を付与します。
# cp -pi /etc/sudoers /etc/sudoers.YYYYMMDD
# vim /etc/sudoers
ppmng  ALL=(ALL)       ALL

・rootユーザでの作業を終了します。
# exit

・新規ユーザのログイン確認
$ ssh appmng@xxx.xxx.xxx.xxx
$ uname -n
⇒ホスト名が表示される
$ id
uid=500(appmng) gid=500(appmng) 所属グループ=500(appmng)


以上です。

2010年1月8日金曜日

[Env] プロンプトの表示を変更する

LinuxやMacOSXでプロンプトの表示を変更したい場合があります。

ホームディレクトリ内の.bash_profile(ない場合は新規作成)に下記のように設定を加えることで実現できます。

export PS1=’[\u@\h \W]\$ ‘

[各種指定の意味]
\d 日付
\h ホスト名
\n 改行
\s シェルの名前
\t 時間
\u ユーザー名
\w ワークディレクトリ
\W ワークディレクトリのベース名
\# コマンド番号
\! ヒストリ番号
\$ 有効なUIDが0なら「#」、それ以外なら「$」
\nnn 8進数での文字コード
\\ バックスラッシュそのもの
\[ 非表示文字の開始
\] 非表示文字の終了


 /etc/bashrc,/etc/profileと,各ユーザーごとの.bash_rc,.bash_profileの間には,“呼び出し関係” がある。.bash_profileは,.bashrcを,.bashrcは,/etc/bashrcを読み出すようにあらかじめ指定されている。このため,あるユーザーがbashを起動すると,まず最初に全ユーザー共通の設定内容が適用され,そこに各ユーザーごとの個別の設定が上書きされる。
システムへのログイン時には,.bash_profileと/etc/profileが読み出される。その後,例えばGNOME端末などのシェルを起動するたびに,.bashrcが読み込まれる。しかし,.bash_profileは読み込まれない。従って,ログイン直後に1度だけ実行させたいプログラムは.bash_profileに記述するべきである。


引用元:http://itpro.nikkeibp.co.jp/article/Keyword/20070831/280849/