« 削除したユーザが、repquota で表示されるのを削除 | メイン | プロセスcore の保存場所 »
2005年06月09日
FTP 専用のユーザアカウントの登録
質問:
/etc/passwd に通常通りにアカウントを登録すると
telnet, rlogin が出来ますが、ftp によるアクセス
だけを許可し、ローカル及びリモートに関係なく、
他のログインを拒否するための設定方法を教えて
いただけますでしょうか。
---------------------------------------------
回答:
ご要望の動作を実現する一般的な方法としましては、
該当アカウントに対して無効なログイン・シェルを
設定する方法がございますので、ご紹介させていた
だきます。
設定手順:
1. 該当ユーザーのログイン・シェルを無効なものに設定する。
例えば /nosuchshell のように存在しないファイルを設定したり、
/bin/true のように即座に終了するコマンドを指定します。
# vi /etc/passwd
:
ftp-only:x:1000:100:ftp access only:/tmp:/nosuchshell
2. 設定した無効なシェルを、/etc/shells に登録する
登録したシェルがログイン・シェルとして利用可能なものになる
ように /etc/shells に登録しておく必要があります。(登録し忘
れますと、ログイン出来なくなるだけではなく、ftp によるアク
セスも出来なくなってしまいます)
# vi /etc/shells
:
/bin/sh
/bin/csh
:
/nosuchshell
[ 注意事項 ]
/etc/shells ファイルには、/nosuchshell だけではなく、標準で
提供されておりますシェル(/bin/sh, /bin/csh 等)も登録して
おく必要があります。/etc/shells ファイルが存在する場合に、
デフォルトのシェルを登録し忘れますと、そのシェルを利用して
いるユーザの ftp が出来なくなります。
デフォルトのシェルについては、man shells に記載がございます
ので、ご参照下さい。
検証結果:
・/etc/shells に /nosuchshell を登録し、ftp を実施
local% ftp remote_host
Connected to remote_host.
220 remote_host FTP server (SunOS 5.8) ready.
Name (remote_host:user1): ftp-only
331 Password required for ftp-only.
Password:
230 User ftp-only logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/tmp" is current directory.
ftp> dir
229 Entering Extended Passive Mode (|||32791|)
150 ASCII data connection for /bin/ls (fe80::a00:20ff:xxxx:xxxx,32960) (0 bytes).
合計 98
drwxrwxrwt 6 root sys 314 6月 6日 11:05 .
drwxr-xr-x 30 root root 1024 1月 27日 16:50 ..
drwxrwxr-x 2 root root 104 6月 6日 11:05 .X11-pipe
drwxrwxr-x 2 root root 104 6月 6日 11:05 .X11-unix
drwxrwxrwx 2 root root 107 6月 6日 11:05 .pcmcia
srwxrwxrwx 1 root root 0 6月 6日 11:05 jd_sockV6
-rw-rw-r-- 1 root sys 6448 6月 6日 11:04 ps_data
drwx------ 2 root root 110 6月 6日 11:05 smc898
226 ASCII Transfer complete.
539 bytes received in 0.028 seconds (18.55 Kbytes/s)
ftp> bye
221 Goodbye.
local%
・ftp-only ユーザで rlogin が失敗することを確認します。
local% rlogin remote_host -l ftp-only
Password:
Last login: Mon Jun 6 11:11:42 from fe80::a00:20ff:
No shell
remote_host への接続を切断しました。
local%
・/etc/shells に nosuchshell を登録しない場合、ftp が失敗します。
local% ftp remote_host
Connected to remote_host.
220 remote_host FTP server (SunOS 5.8) ready.
Name (remote_host:user1): ftp-only
331 Password required for ftp-only.
Password:
530 Login incorrect.
Login failed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> bye
221 Goodbye.
local%
投稿者 AJ : 2005年06月09日 17:20
トラックバック
このエントリーのトラックバックURL:
http://www.factory-aj.com/cgi/mt/mt-tb.cgi/70