hns - 日記自動生成システム - Version 2.19.7

void GraphicWizardsLair( void ); //

otsune GWL
FreeBSD, AfterEffects, RETAS, animo, DigitalAnime, Linux, Mac OS, Win2k

[Who is otsune?] [title] [message] [Policy] [注目エントリー] [top]
Twitter Status :


Namazu for hns による簡易全文検索
詳しくは 詳細指定/ヘルプを参照して下さい

検索式:

先月 2004年01月 来月
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31


2004年01月08日(木) [長年日記]

#1 [work][unix] WinSCPとscponlycで作るchrootなデータやり取りサーバーおぼえ書き

FreeBSD 4.9R-p1だけどLinuxでも大差は無いはず。
適当なところでWikiに移動したほうが良さそうな分量になっているな。

1 概要:

ftp使
port

SCP使ftpWinSCP使
使OpenSSH使
WinSCP使proftpdchroot *1 scponly_ chroot
WinSCP 3.4.2_ 使
(20040116:WinSCP 3.5使)
Mac OS X使 Fugu - A Mac OS X SFTP, SCP and SSH Frontend._ 使

1 ftpと比較した場合:

WinSCP + scponlycの弱点
  • 転送速度がftpより多少遅い(CPUパワー依存?)
  • scponlycサーバーよりもftpサーバーのほうが実稼動が多い(未知のバグがあるかも)
  • chrootツリーのアップデートがメンドクサイ
長所
  • パスワードが漏れて不正アクセスされる可能性は無い
  • パスワードという記憶に頼った認証方法ではなく、秘密鍵ファイルを使った認証になるので、ファイルの物理管理をしっかりするだけで済む
  • 機密性の強度はOpenSSHに依存
  • zlib圧縮が使えるので、画像ファイルやテキストなどは帯域を節約して転送できる(可能性がある)
  • サーバーのファイアーウォールは、port 22だけを空けて管理すれば良いので非常に楽

1 portsツリーでscponlyをchrootサポートでビルドする:

cd /usr/ports/shells/scponly
make -DWITH_SCPONLY_CHROOT -DWITH_SCPONLY_WINSCP install
個人的に-DWITH_SCPONLY_RSYNCも指定している。
portupgradeでもKNOBが付くように/usr/local/etc/pkgtools.confのMAKE_ARGS欄に
'shells/scponly' => '-DWITH_SCPONLY_CHROOT -DWITH_SCPONLY_RSYNC -DWITH_SCPONLY_WINSCP',
を書くことを忘れずに。

1 /etc/shellにscponlycを追加する:

echo `which scponlyc` >> /etc/shells
ついでにchroot無しの普通のscponlyも追加しておいても良いと思う。
echo `which scponly` >> /etc/shells

1 winscpグループの追加:

サーバー側のファイルの読み書き用にWinSCP共通グループの「winscp」を作る。gid 40000は例。
pw groupadd winscp -g 40000

1 /etc/pw.confを設定する:

scponlyでデータのやり取りをするアカウントは、uidをずらしておいたほうが管理しやすい。
下記の数値とhomeは例。
minuid 50000
mingid 50000
home /path/to/winscp_jail/home/
shellpath /usr/local/sbin
defaultshell scponlyc

1 setup_chroot.shをメンテ用に退避しておく:

work/scponly-3.8/config.hとwork/scponly-3.8/setup_chroot.shを、今後のアカウント追加用に${HOME}/scponly/とかに退避しておく。
mkdir ~/scponly
cp work/scponly-3.8/config.h ~/scponly/
cp work/scponly-3.8/setup_chroot.sh ~/scponly/

1 setup_chroot.shにpatch:

長くなったので下記参照。

1 アカウントを追加してchrootツリーを作成する:

cd ~/scponlyしてsh setup_chroot.shする。
enter the home directory you wish to set for this user:
でchrootツリーのディレクトリを入力。
Install for what username?
でアカウント名を入力。
patchを当てたスクリプトの場合は、upload directoryも入力する。 後日にアカウントを追加することになったら、退避したconfig.hとsetup_chroot.shが有れば同様の手順で可能。

1 取引先に公開鍵と秘密鍵を作成してもらう:

公開鍵/秘密鍵生成 for OpenSSH2_ を見てもらい、puttygen.exeで作成してもらう。
パスフレーズ管理とかPageant.exeで便利に使う方法とかは関与しない。(調べるためのポインタを提示しておくのも有りかも?)
公開鍵だけメールでテキストとして送ってもらう。

1 貰った公開鍵を.ssh/authorized_keysに登録する:

ssh-keygen -X -f 貰ったputty公開鍵テキスト
で変換できる。
変換した公開鍵を作成したアカウントの.ssh/authorized_keysに追記する。

1 WinSCPでログインしてもらう:

WinSCPで、scponlyサーバーのFQDNもしくはIPアドレス・アカウント名・秘密鍵を指定してログインすると、パスフレーズを聞かれるので入力します。
ファイルのやり取りが出来ます。
場合によりWinSCPの設定/SSHのプロトコルオプションの「圧縮を有効」をオンにするのを忘れずに。

1 サーバー側ではSambaでchrootツリーを共有する:

WinSCP chrootwinscp
smb.conf
[winscp]
 available = yes
 comment = WinSCP on %h
 browseable = yes
 writeable = yes
 valid users = @winscp
 force create mode = 0664
 force directory mode = 0775
 create mode = 775
 directory mode = 775
 force group = winscp
 veto files = /.ssh/usr/bin/etc/lib/
 path = /path/to/winscp_chroot/

[global]coding system = 2.2.8EUC
使
veto files = /.??*/*.{*}/ globalsamba.gr.jpKB

1 サーバー側からWinSCPを使う:

shellを/usr/local/bin/scponlyにしたアカウントなら、chrootしないでディレクトリを上位まで移動できます。
WinSCP管理担当のアカウントを作って、WinSCPでメンテをしてもらうという手もあります。

1 make worldしたら、WinSCPツリーもアップデートする:

退config.hchroot使
grep '#define PROG_' config.h | /usr/bin/cut -f2 -d\" | grep -v ^cd$

lib.sh
FreeBSD 4.9R-p1RSYNC
/usr/lib/libc.so.4
/usr/lib/libcrypto.so.3
/usr/lib/libssh.so.2
/usr/lib/libz.so.2
/usr/libexec/ld-elf.so.1

libc.so.4ld-elf.so.1schg
chflags noschg usr/lib/libc.so.4
chflags noschg usr/libexec/ld-elf.so.1

sysctl kern.securelevel1/etc/rc.confkern_securelevel_enable="NO"securelevel-1
(make installworld)

1 その他雑多なテクニック:

WinSCP chroot用のスケルトンを/usr/local/scponly/skel/とかに用意しておいて。pw useraddの時にpw.confのskeltonで指定するとか。

1 BSDHound: Setting up scponly - limited shell for secure file transfers_:

参考サイト

1 setup_chroot.shのpatch:

えらいadhocな適当patchなので理解せずに使ったら痛い目にあうかも。
変更点
  • chrootツリーのルートパーミッションを555に変更
  • 所有者をアカウントに変更
  • incomingディレクトリをupload directoryとして入力指定可能にした
  • ダウンロード用ディレクトリを「to_ユーザー名」として作成する
  • authorized_keysで公開鍵を置くために.sshディレクトリを500で作成
  • アップロード・ダウンロードディレクトリをwinscpクループにして書き込み可能にした
  • syslogの時刻がUTCになってしまうので、localtimeをインストールするようにした
setup_chroot.sh.diff
--- /usr/ports/shells/scponly/work/scponly-3.8/setup_chroot.sh	Thu Jan  8 04:42:17 2004
+++ setup_chroot.sh	Thu Jan  8 04:42:50 2004
@@ -98,6 +98,12 @@
 	fail "need to specify a username"
 fi
 
+echo -n "Please input the name of a upload directory: "
+read uploaddir
+if [ "x$uploaddir" = "x" ]; then
+	fail "need to specify a upload directory"
+fi
+
 /usr/bin/install -c -o root -g wheel -d $targetdir
 /usr/bin/install -c -o root -g wheel -d $targetdir/usr
 /usr/bin/install -c -o root -g wheel -d $targetdir/usr/bin
@@ -158,14 +164,25 @@
     fi
 fi 
 
-chown 0:0 $targetdir 
+chown $targetuser $targetdir 
+chgrp $targetuser $targetdir 
+chmod 555 $targetdir 
+mkdir $targetdir/.ssh
 if [ -d $targetdir/.ssh ]; then
-	chown 0.0 $targetdir/.ssh
+	chown $targetuser:$targetuser $targetdir/.ssh
+	/usr/bin/touch $targetdir/.ssh/authorized_keys
+	chown $targetuser:$targetuser $targetdir/.ssh/authorized_keys
+	chmod 0500 $targetdir/.ssh
 fi
 
-if [ ! -d $targetdir/incoming ]; then
-	echo -e "\ncreating  $targetdir/incoming directory for uploading files"
-	/usr/bin/install -c -o root -g wheel -o $targetuser -d $targetdir/incoming
+if [ ! -d $targetdir/$uploaddir ]; then
+	echo -e "\ncreating  $targetdir/$uploaddir directory for uploading files"
+	/usr/bin/install -c -m 775 -g winscp -o $targetuser -d $targetdir/$uploaddir
+fi
+
+if [ ! -d $targetdir/to_$targetuser ]; then
+	echo -e "\ncreating  $targetdir/to_$targetuser directory for downloading files"
+	/usr/bin/install -c -m 775 -g winscp -o root -d $targetdir/to_$targetuser
 fi
 
 # the following is VERY BSD centric
@@ -179,3 +196,6 @@
 fi
 
 
+if [ -f /etc/localtime ]; then
+		/usr/bin/install -c -m 444 -o root -g wheel /etc/localtime $targetdir/etc/localtime
+fi

1 lib.sh:

setup_chroot.sh
echochflags noschg
#!/bin/sh
#

# the following is a list of binaries that will be staged in the target dir
BINARIES=`/usr/bin/grep '#define PROG_' config.h | /usr/bin/cut -f2 -d\" | /usr/bin/grep -v ^cd$`

LIB_LIST=`/usr/bin/ldd $BINARIES 2> /dev/null | /usr/bin/cut -f2 -d\> | /usr/bin/cut -f1 -d\( | /usr/bin/grep "^ " | /usr/bin/sort -u`

LDSOFOUND=0
if [ -f /usr/libexec/ld.so ]; then
 LIB_LIST="$LIB_LIST /usr/libexec/ld.so"
 LDSOFOUND=1
fi
if [ -f /lib/ld-linux.so.2 ]; then 
 LIB_LIST="$LIB_LIST /lib/ld-linux.so.2"
 LDSOFOUND=1
fi
if [ -f /usr/libexec/ld-elf.so.1 ]; then
 LIB_LIST="$LIB_LIST /usr/libexec/ld-elf.so.1"
 LDSOFOUND=1
fi

if [ $LDSOFOUND -eq 0 ]; then
 fail i cant find your equivalent of ld.so
fi

/bin/ls /lib/libnss_compat* 2>&1 > /dev/null
if [ $? -eq 0 ]; then
 LIB_LIST="$LIB_LIST /lib/libnss_compat* /lib/ld.so"
fi

if [ "x$LIB_LIST" != "x" ]; then
 for lib in $LIB_LIST; do
 echo $lib
 done
fi
*1: OpenSSHにchroot patchを当てるという方法もある。
Permalink: http://www.otsune.com/diary/2004/01/08/1.html#200401081
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune

#2 [hns] hnsでPREにコンテクスト形式のdiffを貼ったらコメントアウトされて見えなくなる

これは仕様だ。
とりあえずunified形式で貼っておく。
Permalink: http://www.otsune.com/diary/2004/01/08/2.html#200401082
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune

#3 [www] The Trembling of a Leaf: 「やるだけ無駄」と言われたら_






Permalink: http://www.otsune.com/diary/2004/01/08/3.html#200401083
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune

#4 [2ch][anime] アニタイの頭を”チツ”に変換するスレ_



Permalink: http://www.otsune.com/diary/2004/01/08/4.html#200401084
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune

#5 [2ch][anime] 【もしも】あのアニメを出崎が!!【もしも】_





 

 

 

 

3PAN 



Permalink: http://www.otsune.com/diary/2004/01/08/5.html#200401085
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune
Permalink: http://www.otsune.com/diary/2004/01/08/6.html#200401086
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune

#7 [www] リアル「Google八分」?_


GoogleMSNYahoo *2

WDGGoogleGooglewww6.big.or.jp/~beyond/url

7 Google:

Artifact-jp!!()
Web
Google


Google
AdSense?(Adsense?)

7 悪マニは<H1 style="display:none;">を使っているから、悪質な検索対策だと思われて削除された?_:

*2: ?
Permalink: http://www.otsune.com/diary/2004/01/08/7.html#200401087
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune
Permalink: http://www.otsune.com/diary/2004/01/08/8.html#200401088
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune

#9 [www] NTSCの周波数_

まず、4.5MHzに音声の副搬送波があるので、これとビート干渉しないように水平周波数の偶数倍が4.5MHzになるようにしました。もっとも近い値を選んで、
水平周波数は 4.5MHz*286=15.734kHz・・・(カラー)
と決まりました。水平周波数を525(走査線の数)分の1したものがフレーム周波数なので、
フレーム周波数は 15.734kHz/525=29.97Hz

9 変調方式_:

コメントを読む(1) [ コメントする ]

Re: NTSCの周波数 by まのん    2004/01/10 10:37
>4.5MHz/286=15.734kHzですよね?
Permalink: http://www.otsune.com/diary/2004/01/08/9.html#200401089
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune

#10 [neta] シンクロニシティ?

Matz氏と塩兄ちゃん氏が同時にCitrusをネタにしたことを板垣風に表現すると「シンクロニシティは存在するっ!!」って感じか。
Permalink: http://www.otsune.com/diary/2004/01/08/10.html#2004010810
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune
Permalink: http://www.otsune.com/diary/2004/01/08/11.html#2004010811
trackback
このエントリーを含むはてなブックマーク del.icio.us livedoor Clip View blog reactions
Last Updated 2004-01-08 00:00:00 By otsune