http://www2.kiwi-us.com/~mnyu/private-agu/index.htmlへのアクセスコントロール
sshでkiwiにアクセスして複数のuserそれに対応する
パスワードを時々かえる事。
/home/xxxx/passwd
aho ahoというユーザーのpasswdというファイルのセット
この対応は ssh でそのディレクトリにアクセスして .htaccess をcatしたら分かる
簡単な物は
/home/xxxx/pass1 mnyu mxxxx
/home/xxxx/pass2 mnyu yxxxxxx
/home/xxxx/pass3 mnyu kxxxxxxx
などがある
6# su mnyu
6# ssh www2.kiwi-us.com
mnyu@www2.kiwi-us.com's password: wxxxxxx
Last login: Wed May 5 16:17:00 2004 from 50.234.244.43.a
Sun Microsystems Inc. SunOS
5.8 Generic February 2000
tcsh: using dumb terminal settings.
>
> cd /usr/local/apache/bin/
> ls
ab
apxs dbmmanage
htpasswd logresolve
apachectl checkgid
htdigest httpd
rotatelogs
./htpasswd
Usage:
htpasswd [-cmdps]
passwordfile username
htpasswd -b[cmdps]
passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username
password
-c Create a new file.
-n Don't update file; display results on stdout.
-m Force MD5 encryption of the password.
-d Force CRYPT encryption of the password (default).
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than
prompting for it.
On Windows, TPF and NetWare systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.
>
./htpasswd -cmdps
/home/mnyu/passwd mnyu
New password: remxxxxx 8文字
> ls
passwd
public_html できている
> cat passwd
mnyu:{SHA}koRRteXtlceKsal6RDxO5eK/u0o= (passwd = remxxxxx)
/////////////////////////////////////////////////////////////////
.htaccess の内容 apacheマニュアルより
AuthType Basic
AuthName "Restricted Files"
AuthUserFile
/home/mnyu/passwd このファイルをいくつかつくって複数認証OK
require user mnyu 複数OK
/home/mnyu/ 以下に passwd 等いくつか作る
/////////////////////////////////////////////////////////////////
ls -aF
> ./htpasswd -cmdps /home/mnyu/passwdd kaz
New password: k1234
Re-type new password: k1234
Adding password for user kaz
> pwd
/home/mnyu/public_html/win
echo AuthType Basic > .htaccess
echo AuthName \"Restricted Files\" >> .htaccess
echo AuthUserFile /home/mnyu/passwdd >> .htaccess
echo require user kaz >> .htaccess
2回目からは
echo
しなくてもローカルで作成してUPしたらいい
//////////////////////////////////////////////////////////////////////////////////////////
パスワードをいれないで kiwiに loginする 方法
http://www2.kiwi-us.com/~mnyu/FreeBSD/ssh.ok8-28for-local.tar.gz
http://www.geocities.jp/turtle_wide/tools/sshpass.html
ローカルgyuで mnyuになり(root でもkazでもいい 別のPCでもいい 出来た
id_rsa & id_rsa.pub
の user group さえ mnyu member にしたらいい )
# ssh-keygen -b 1024 -t rsa -C mnyu@www2.kiwi-us.com
パスフレーズには何も入力しない。 そうすると .ssh/に
id_rsa 秘密鍵 & id_rsa.pub公開鍵 ができます公開鍵 をリネームして kiwiの
~/.sshに置く
kiwi側での操作
touch authorized_keys2
echo > authorized_keys2 念のため 空のファイルをコピー
echo > (ここにgyuのmnyuのid_rsa.pubの内容をペースト) 別のホスト kaz からloginしたかったら
kazuで id_rsa.pub を作りそのid_rsa.pubの内容を再度
echo >> (ここにkazのid_rsa.pubの内容をペースト)
これで複数の
gyuのmnyuのid_rsa.pubの内容が
kiwiのmnyuのauthorized_keys2にコピーした
kiwi側で ls -al の結果が下のようにする
-rwx---r-- 1 mnyu
member 231 Aug 26 14:38
authorized_keys2
この2つのファイルは cat id_rsa.pub >> authorized_keys2 としてコピーして良い
kiwi側で ls -al の結果
drwxr-xr-x 2 mnyu
member 512 Aug 26 08:19 .ssh
-rwx---r-- 1 mnyu
member 231 Aug 26 14:38
authorized_keys2
必ずこのようにする事
ローカルがrootである場合は rootの .ssh/をrenameしてから /home/mnyu/.sshを
/rootに
シンボリックリンクをはり
ssh mnyu@www2.kiwi-us.com で入る
上の設定が終ると
ローカル/hpp/1.tar.gzを kiwi の /home/mnyu/public_html/ に コピー出来る
scp /hpp/1.tar.gz mnyu@www2.kiwi-us.com:/home/mnyu/public_html/ 順
scp mnyu@www2.kiwi-us.com:/home/mnyu/README /home/mnyu/test 逆