Ubuntu

Ubuntu 12.04 サーバー再構築(1)

いや、困った。サーバーが動かなくなった。

発端は、ちょいちょい発生していたdbusのエラーの原因がわからなくて、色々とファイルの出し入れをしていたことだろうと思われる・・・が、理由はわからなくて、fsckしたらほとんどのファイルが消失してしまった。

ここから広告
広告
広告ここまで


データを保管するディレクトリはかろうじて残っている模様。
なので、復旧はあきらめてサーバーを一から再構築することにした。

Ubuntu 12.04LTS Server

動かすサービスは以下の通り。いやはや、かなり面倒な作業になりそう。

サービス 用途
sshd 外部から操作forモニタレス運用
samba ファイル共有、WINSサーバー
dhcpd IPアドレスを自動で振る
vsftpd Firefoxの設定を保管
bind9 ホスト名でアクセスできる環境
l2tpd VPN接続
ipsec VPN接続
vncserver 外出先から色々操作

思い出したらどんどんここに追記していく。

構築は楽ちんなのでVMware Playerで行い、サービスがうまく動くようになったら V2P する。

■VMwareで仮想マシンを作る

ターゲットマシンがPentium4 HyperThreadingなので、2コアで作ってみた。
どうなるのかはわからないけど、とりあえず2コアで作ってみて、1コアに変更して試してみて、問題がないようならば育成を進める方針。

→ 結果としては問題なさそうだった。

■Ubuntu12.04 Serverのセットアップ

これは自動で済ませて終了。

■rootのパスワード設定

$ sudo passwd

■sshdを導入

$ sudo apt-get install ssh

これで Teraterm で接続。

接続は、RSAで認証したいので、以下を実行。

$ mkdir .ssh
$ ssh-keygen -t rsa
ファイル名はデフォルト、パスフレーズを入力。
$ cd .ssh
$ mv rsa_id.pub authorized_keys
$ chmod 600 authorized_keys

PC側に秘密キーを持ってきたいので、Teraterm上で以下を実施して、結果をコピー、PC側でファイルにする。

$ cat id.pub

次に、sshdの設定を以下の通り変更。

$ sudo vi /etc/ssh/sshd_config

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes
PasswordAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

UseDNS no

rsaキーのみ有効にして、パスワードによるログインは許容しない。
DNSはいずれサーバーを立てるけど、それまでは我慢。

で、sshdを再起動。

$ sudo service ssh restart

Teratermで接続を試してから、現在操作中のターミナルを閉じる。

■Ubuntu-Desktopを導入

GUIは絶対に使うので入れてしまう。

$ sudo apt-get install ubuntu-desktop

なんと、3時間待ち。今日はこれにて。

■朝起きて追記

朝起きたらインストールは終わっていた。

$ sync
$ sudo reboot

GUIが起動。

GUIにて
・日本語サポートを追加
・キーボードを日本語に変更
・時間を日本に、表記も日本に変更
までを実行。

その後、sshで接続をして以下を実行。

$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sync
$ sudo reboot

まずはベースができた。

ここから広告
広告
広告ここまで

コメントはこちらから お気軽にどうぞ ~ 投稿に関するご意見・感想・他