sshdで2つのポートを使い分ける(inetd版)
id:messier42さんにinetd起動でもできるというので試して見た.情報提供ありがとうございます.
前回いい忘れていたが2つのポートで設定を変えるというのは何が重要かと言うと,sshdの起動時に-fで使用する設定ファイルを変えられる点である.
前提条件
・sshdはinetdで起動
・2つポートを使う
・一つは22で鍵のみ,もう一つは57431でパスワードでも入れる
inetdの起動
vi /etc/rc.conf inetd_enable="YES" #sshd_enable="YES" #opensshd_enable="YES"
inetdを起動して,sshdは起動しないようにする
最後に以下を付け足す(viならctrl+Gで一番下に行く)
vi /etc/services sshp 57431/tcp #ssh passwd auth
22番用の設定ファイルの作成,パスワード認証を無くす
cp /etc/ssh/sshd_config /etc/ssh/sshd_config_passwd
vi /etc/ssh/sshd_config
ListenAddress ***.***.** #ここでIPを指定しないと動かなかったので指定
PasswordAuthentication no
ChallengeResponseAuthentication no
パスワード認証用の設定ファイル作成
vi /etc/ssh/sshd_config_passwd
Port 57431
リモートから操作している場合,sshからtelnetに切り替える作業をするためtelnetを使えるようにする.
vi /etc/inetd.conf telnet stream tcp nowait root /usr/libexec/telnetd telnetd ssh stream tcp nowait root /usr/sbin/sshd sshd -i -4 sshp stream tcp nowait root /usr/sbin/sshd sshd -i -4 -f /etc/ssh/sshd_config_passwd
inetdの開始
/etc/rc.d/inetd start
telnetでlogin
すでにinetdがあるならば再起動させる
ps axf |grep inetd 1201 ?? Is 0:00.00 /usr/sbin/inetd -wW -C 60 kill -HUP 1201 >|| sshdを切る.stopで無理ならonestopを使う. >|sh| /etc/rc.d/sshd stop or /usr/local/etc/rc.d/opensshd stop
inetdの再起動
ps axf |grep inetd 1514 ?? Is 0:00.26 /usr/sbin/inetd -wW -C 60 kill -HUP 1514
誤字と設定の順番を変更