Ubuntu 9.10 Server 初期設定メモ


インストール後の諸々の設定。

固定IPへ変更

/etc/network/interfacesを編集。

$ sudo vi /etc/network/interfaces

dhcpからstaticに変更する。

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx


続いて/etc/resolve.confも編集

$ sudo vi /etc/resolve.conf

VMwareの場合はネームサーバはGatewayと同じでよし。

nameserver xxx.xxx.xxx.xxx

何はともあれパッケージを更新

Kernelとかもアップデートされるかもしれないので、アップデート後は次の作業に移る前に、一応再起動する。

$ sudo aptitude update
$ sudo aptitude full-upgrade
$ sudo reboot

AppArmorは無効にしときます。

9.10ではデフォルトでAppArmorがKernel組み込みで動いている。セキュリティを考えると止めないほうがいいだろうけど、SELinux同様にプチはまりの元になるので(てか嵌まったので)止める。以前のバージョンはサービスを止めればよかったみたいだけど、組み込みになってるのでKernelの起動オプションを指定して止める。


/etc/default/grubを編集

$ sudo vi /etc/default/grub

GRUB_CMDLINE_LINUXにapparmor=0を追加する。

GRUB_CMDLINE_LINUX="apparmor=0"

編集したらupdate-grubを実行して、/boot/grub/grub.cfgを更新する。

$ sudo update-grub
$ sudo reboot

AppArmorの細かい話は以下のリンクあたりを参照。
https://help.ubuntu.com/community/AppArmor

OpenSSHの設定を公開鍵認証に変更。

ローカルのVMwareで使用するだけならパスワード認証でも良いんだけど、公開鍵認証を習慣づけとくということで。キーペアはクライアント側で作成して公開鍵をサーバ側へ設置するというスタンス。


まずはサーバ側で公開鍵を保存するディレクトリを作成しておく。

$ cd ~/
$ mkdir .ssh
$ chmod 700 .ssh


そしてMac側でキーペアを作成。Windowsは知らん。

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/yourname/.ssh/id_rsa):  Enter
Enter passphrase (empty for no passphrase):  パスフレーズを入力してEnter
Enter same passphrase again:  もう一度入力してEnter
Your identification has been saved in /Users/yourname/.ssh/id_rsa.
Your public key has been saved in /Users/yourname/.ssh/id_rsa.pub.


公開鍵をサーバへ転送。(これもMac側の作業)

$ cd ~/.ssh
$ scp id_rsa.pub yourname@xxx.xxx.xxx.xxx:.ssh/authorized_keys


転送した公開鍵のパーミッションを変更する。(ここからはサーバ側の作業)

$ cd ~/.ssh
$ chmod 600 authorized_keys


sshd_configでパスワード認証とrootログインを禁止する。

$ sudo vi /etc/ssh/sshd_config

変更するとこだけ抜粋。

PermitRootLogin yes
           ↓               rootログイン禁止
PermitRootLogin no

#PasswordAuthentication yes
           ↓                パスワード認証禁止
PasswordAuthentication no

保存したら、sshdを再起動

$ sudo /etc/init.d/ssh restart


後はMacからsshで接続してみて「Enter your password for the SSH key "id_rsa".」って聞いてきて、ログイン出来ればOK。