CentOS5 OpenSSHのセットアップ | Subaru's Husband

Subaru's Husband

python、linux、バイクなんかのネタを書きます。
一応security業界でご飯を食べてます。
備忘録がメインだと思うので、未来の自分が助かれば最高。

最新のOpenSSHをインストールした際のメモ。
いつもここのサイトを参考にしてます。http://centossrv.com/

#yum remove openssh ←既存のopensshを削除

#yum -y install pam-devel
#cd /tmp
[root@localhost tmp]# wget http://ftp.jaist.ac.jp/pub/OpenBSD/OpenSSH/portable/openssh-5.6p1.tar.gz
[root@localhost tmp]# tar xvzf openssh-5.6p1.tar.gz

[root@localhost tmp]# vi openssh-5.3p1/contrib/redhat/openssh.spec ← specファイル編集
# Do we want to disable building of x11-askpass? (1=yes 0=no)
%define no_x11_askpass 0

%define no_x11_askpass 1 ← x11_askpassの無効化

# Do we want to disable building of gnome-askpass? (1=yes 0=no)
%define no_gnome_askpass 0

%define no_gnome_askpass 1 ← gnome_askpassの無効化

%configure \
configure --without-zlib-version-check \ ← 追加(zlibのバージョンチェック無効化)
--sysconfdir=%{_sysconfdir}/ssh \

[root@localhost contrib]# cd openssh-5.6p1/contrib/
[root@localhost contrib]# rm -rf solaris/ hpux/ suse/ caldera/ cygwin/ aix/
[root@localhost tmp]# cd ../../
[root@localhost tmp]# tar czvf openssh-5.6p1.tar.gz openssh-5.6p1/
[root@localhost tmp]# rpmbuild -tb --clean openssh-5.6p1.tar.gz
エラー: ビルド依存性の失敗:
openssl-devel は openssh-5.6p1-1.i386 に必要とされています
glibc-devel は openssh-5.6p1-1.i386 に必要とされています
krb5-devel は openssh-5.6p1-1.i386 に必要とされています
[root@localhost tmp]# yum -y install openssl-devel glibc-devel krb5-devel

[root@localhost tmp]#rpmbuild -tb --clean openssh-5.6p1.tar.gz
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
エラー: /var/tmp/rpm-tmp.12439 の不正な終了ステータス (%build)

[root@localhost tmp]#yum install gcc* compat-gcc* compat-glibc* compat-lib*

※ここでCentOSに開発ツールが入ってない事に気づいて、GUIからインストールしました。
※他の方はわざわざ個別にセットアップする必要はないかも。

[root@localhost tmp]#rpmbuild -tb --clean openssh-5.6p1.tar.gz

書き込み完了: /usr/src/redhat/RPMS/i386/openssh-5.6p1-1.i386.rpm
書き込み完了: /usr/src/redhat/RPMS/i386/openssh-clients-5.6p1-1.i386.rpm
書き込み完了: /usr/src/redhat/RPMS/i386/openssh-server-5.6p1-1.i386.rpm
書き込み完了: /usr/src/redhat/RPMS/i386/openssh-debuginfo-5.6p1-1.i386.rpm

[root@localhost tmp]# rpm -Uvh /usr/src/redhat/RPMS/i386/openssh-5.6p1-1.i386.rpm
準備中... ########################################### [100%]
1:openssh ########################################### [100%]
[root@localhost tmp]# rpm -Uvh /usr/src/redhat/RPMS/i386/openssh-clients-5.6p1-1.i386.rpm
準備中... ########################################### [100%]
1:openssh-clients ########################################### [100%]
[root@localhost tmp]# rpm -Uvh /usr/src/redhat/RPMS/i386/openssh-server-5.6p1-1.i386.rpm
準備中... ########################################### [100%]
1:openssh-server ########################################### [100%]
[root@localhost tmp]# rpm -Uvh /usr/src/redhat/RPMS/i386/openssh-debuginfo-5.6p1-1.i386.rpm
準備中... ########################################### [100%]
1:openssh-debuginfo ########################################### [100%]

[root@localhost tmp]# rm -rf /usr/src/redhat/RPMS/i386/openssh-*
[root@localhost tmp]# rm -rf openssh-5.6p1*

[root@localhost tmp]# nano /etc/rc.d/init.d/sshd
start()
{
# Create keys if necessary
do_rsa1_keygen
do_rsa_keygen
do_dsa_keygen

echo -n $"Starting $prog:"
#initlog -c "$SSHD $OPTIONS" && success || failure  ← コメントアウト
$SSHD $OPTIONS && success || failure        ← 追加
RETVAL=$?
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/sshd
echo
}

root@localhost tmp]# # /etc/rc.d/init.d/sshd start

[root@localhost tmp]# whereis chkconfig
chkconfig: /sbin/chkconfig /usr/share/man/man8/chkconfig.8.gz
[root@localhost tmp]# /sbin/chkconfig sshd on ← SSHサーバー自動起動設定
[root@localhost tmp]# /sbin/chkconfig --list sshd
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off