出先などでどうしてもログインしたい場合鍵が無くて困ることがあるので、一定時間だけパスワード認証できるユーザーを作った。
仕組みは以下のとおり
1.SUIDのセットされたperlスクリプトで実行するコマンドはusermod --lockコマンド →suidperlについて
2.アンロックされる
3.sshのパスワード認証によってログインする ※1
4.cronにusermod --unlockを仕込んでおく
※1 特定のユーザーのみパスワード認証を許可する
hogeuserが今回の対象とする場合
Match User hogeuser PasswordAuthentication yes AllowTcpForwarding no
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/suidperl | |
$ENV{PATH}="/usr/sbin/"; | |
system "usermod --unlock sotossh" and die $!; | |
print <<"HTML"; | |
Content-type: text/html; | |
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<html> | |
<body> | |
<h1>scrit run!</h1> | |
</body> | |
</html> | |
HTML |
参考リンク
http://d.hatena.ne.jp/isseium/20100923/1285225757