Linux備忘録
Amebaでブログを始めよう!

sambaでディレクトリ共有

sambaでディレクトリ共有をやってみた。

sambaでディレクトリ共有する場合の設定方法(共有ディレクトリは、/srv/samba/share/とする)
ユーザとして、
michael,minerva
だけのアクセスを許可し、
書き込み、可視とする場合の設定方法

(1)Linuxユーザとして、minervaを登録する。(michaelは既に登録済み)
sudo useradd minerva

 尚、ファイルを共有したいが、Linuxにログインする必要がないために、security確保の目的でログイン不可にしたいという場合は、

@IT(ログイン不可のユーザーアカウントを作成するには)によれば、

ユーザ作成時に、ルート権限で、

単に

useradd ユーザーアカウント

でなく、

useradd -s /bin/false <ユーザーアカウント>

とやれば良い。

尚、既に作成してしまったユーザに対して、ログイン不可にする場合は、

usermod -s /bin/false <ユーザーアカウント>

とやれば良い。


(2)sambaユーザとして、minervaを登録する。(michaelは既に登録済み)
sudo smbpasswd -a minerva

(3)共有ディレクトリの作成
sudo mkdir -p /srv/samba/share/
sudo chmod 777 /srv/samba/share/



(4)
/etc/samba/smb.conf
ファイルに、
下の行を追加する。


[share]
path = /srv/samba/share
writeable = yes
; browseable = yes
valid users = michael, minerva




(5)
尚、日本語ファイルを扱う場合には、[global]に下記3行を追加
unix chareset = UTF-8
dos charset = CP932
display charset = UTF-8


必要かどうか不明なのだが、

sudo service smbd restart

を一応、やっておく。




他のコンピュータよりアクセスしてみたところ、無事に成功。

rootkit 探知

別にserverを公開するつもりはないが、気分的な問題でrootkit探知ソフトをinstallしてみた。
本来ならば、OS install直後にやるべきなのであろうが、別にserverを構築しているわけでもないと言い訳をして・・・。
michael@michael:~$ sudo aptitude install chkrootkit
[sudo] password for michael:
以下の新規パッケージがインストールされます:
  chkrootkit
0 個のパッケージを更新、 1 個を新たにインストール、 0 個を削除予定、0 個が更新されていない。
309kB のアーカイブを取得する必要があります。 展開後に 844kB のディスク領域が新たに消費されます。
取得:1 http://jp.archive.ubuntu.com/ubuntu/ maverick/main chkrootkit i386 0.49-4 [309kB]
309kB を 0秒 秒でダウンロードしました (522kB/s)
パッケージを事前設定しています ...
未選択パッケージ chkrootkit を選択しています。
(データベースを読み込んでいます ... 現在 152428 個のファイルとディレクトリがインストールされています。)
(.../chkrootkit_0.49-4_i386.deb から) chkrootkit を展開しています...
man-db のトリガを処理しています ...
chkrootkit (0.49-4) を設定しています ...
michael@michael:~$ sudo chkrootkit
ROOTDIR is `/'
Checking `amd'...                                           not found
Checking `basename'...                                      not infected
Checking `biff'...                                          not found
Checking `chfn'...                                          not infected
Checking `chsh'...                                          not infected
Checking `cron'...                                          not infected
Checking `crontab'...                                       not infected
Checking `date'...                                          not infected
Checking `du'...                                            not infected
Checking `dirname'...                                       not infected
Checking `echo'...                                          not infected
Checking `egrep'...                                         not infected
Checking `env'...                                           not infected
Checking `find'...                                          not infected
Checking `fingerd'...                                       not found
Checking `gpm'...                                           not found
Checking `grep'...                                          not infected
Checking `hdparm'...                                        not infected
Checking `su'...                                            not infected
Checking `ifconfig'...                                      not infected
Checking `inetd'...                                         not infected
Checking `inetdconf'...                                     not found
Checking `identd'...                                        not found
Checking `init'...                                          not infected
Checking `killall'...                                       not infected
Checking `ldsopreload'...                                   not infected
Checking `login'...                                         not infected
Checking `ls'...                                            not infected
Checking `lsof'...                                          not infected
Checking `mail'...                                          not found
Checking `mingetty'...                                      not found
Checking `netstat'...                                       not infected
Checking `named'...                                         not found
Checking `passwd'...                                        not infected
Checking `pidof'...                                         not infected
Checking `pop2'...                                          not found
Checking `pop3'...                                          not found
Checking `ps'...                                            not infected
Checking `pstree'...                                        not infected
Checking `rpcinfo'...                                       not infected
Checking `rlogind'...                                       not found
Checking `rshd'...                                          not found
Checking `slogin'...                                        not infected
Checking `sendmail'...                                      not found
Checking `sshd'...                                          not infected
Checking `syslogd'...                                       not tested
Checking `tar'...                                           not infected
Checking `tcpd'...                                          not infected
Checking `tcpdump'...                                       not infected
Checking `top'...                                           not infected
Checking `telnetd'...                                       not found
Checking `timed'...                                         not found
Checking `traceroute'...                                    not found
Checking `vdir'...                                          not infected
Checking `w'...                                             not infected
Checking `write'...                                         not infected
Checking `aliens'...                                        no suspect files
Searching for sniffer's logs, it may take a while...        nothing found
Searching for rootkit HiDrootkit's default files...         nothing found
Searching for rootkit t0rn's default files...               nothing found
Searching for t0rn's v8 defaults...                         nothing found
Searching for rootkit Lion's default files...               nothing found
Searching for rootkit RSHA's default files...               nothing found
Searching for rootkit RH-Sharpe's default files...          nothing found
Searching for Ambient's rootkit (ark) default files and dirs... nothing found
Searching for suspicious files and dirs, it may take a while... The following suspicious files and directories were found:  
/usr/lib/pymodules/python2.6/.path /usr/lib/thunderbird-3.1.10/.autoreg /usr/lib/jvm/.java-6-openjdk.jinfo /usr/lib/xulrunner-1.9.2.18/.autoreg /usr/lib/firefox-3.6.18/.autoreg

Searching for LPD Worm files and dirs...                    nothing found
Searching for Ramen Worm files and dirs...                  nothing found
Searching for Maniac files and dirs...                      nothing found
Searching for RK17 files and dirs...                        nothing found
Searching for Ducoci rootkit...                             nothing found
Searching for Adore Worm...                                 nothing found
Searching for ShitC Worm...                                 nothing found
Searching for Omega Worm...                                 nothing found
Searching for Sadmind/IIS Worm...                           nothing found
Searching for MonKit...                                     nothing found
Searching for Showtee...                                    nothing found
Searching for OpticKit...                                   nothing found
Searching for T.R.K...                                      nothing found
Searching for Mithra...                                     nothing found
Searching for LOC rootkit...                                nothing found
Searching for Romanian rootkit...                           nothing found
Searching for Suckit rootkit...                             nothing found
Searching for Volc rootkit...                               nothing found
Searching for Gold2 rootkit...                              nothing found
Searching for TC2 Worm default files and dirs...            nothing found
Searching for Anonoying rootkit default files and dirs...   nothing found
Searching for ZK rootkit default files and dirs...          nothing found
Searching for ShKit rootkit default files and dirs...       nothing found
Searching for AjaKit rootkit default files and dirs...      nothing found
Searching for zaRwT rootkit default files and dirs...       nothing found
Searching for Madalin rootkit default files...              nothing found
Searching for Fu rootkit default files...                   nothing found
Searching for ESRK rootkit default files...                 nothing found
Searching for rootedoor...                                  nothing found
Searching for ENYELKM rootkit default files...              nothing found
Searching for common ssh-scanners default files...          nothing found
Searching for suspect PHP files...                          nothing found
Searching for anomalies in shell history files...           nothing found
Checking `asp'...                                           not infected
Checking `bindshell'...                                     not infected
Checking `lkm'...                                           chkproc: nothing detected
chkdirs: nothing detected
Checking `rexedcs'...                                       not found
Checking `sniffer'...                                       lo: not promisc and no packet sniffer sockets
eth1: not promisc and no packet sniffer sockets
Checking `w55808'...                                        not infected
Checking `wted'...                                          chkwtmp: nothing deleted
Checking `scalper'...                                       not infected
Checking `slapper'...                                       not infected
Checking `z2'...                                            user michael deleted or never logged from lastlog!
Checking `chkutmp'...                                       chkutmp: nothing deleted
Checking `OSX_RSPLUG'...                                    not infected
michael@michael:~$


Searching for suspicious files and dirs, it may take a while... The following suspicious files and directories were found:  
/usr/lib/pymodules/python2.6/.path /usr/lib/thunderbird-3.1.10/.autoreg /usr/lib/jvm/.java-6-openjdk.jinfo /usr/lib/xulrunner-1.9.2.18/.autoreg /usr/lib/firefox-3.6.18/.autoreg

『疑わしいファイルとディレクトリを発見。え・・・?』
と思ったが、調べたところ、何でもないことが判り、一安心。
他にはinfectedだのfoundだの表示されていないことだし、まぁ、たぶん問題ないのであろう・・・。

sshでの接続

sshでの接続
当然であるが、serverとなる側に、
openssh-server
をinstallする必要がある。
当然と言いながら、最初は知らなかったのだが・・・。
openssh-serverをinstallしない状態で、
michael@michael:~$ sudo ssh minerva@192.168.100.10
などとやっても、
ssh: connect to host 192.168.100.10 port 22: Connection refused
というふうに拒否されるだけである。外部にserverを公開する場合には、一般的にport 22以外を使用するのでしょうかね・・・。
server側にopenssh-serverをinstallした後で、
michael@michael:~$ ssh -l minerva 192.168.100.10 (または、sudo ssh minerva@192.168.100.10)
とやれば、
The authenticity of host '192.168.100.10 (192.168.100.10)' can't be established.
RSA key fingerprint is ca:18:81:a2:5c:99:1c:3f:4b:4a:18:6d:ff:9e:6d:5e.
Are you sure you want to continue connecting (yes/no)?
と聞いてくるので、管理者に鍵が正しいかどうか確認し、正しければ、yes
と入力。
すると、
Warning: Permanently added '192.168.100.10' (RSA) to the list of known hosts.
minerva@192.168.100.10's password:
Linux minerva 2.6.35-28-generic-pae #50-Ubuntu SMP Fri Mar 18 20:43:15 UTC 2011 i686 GNU/Linux
Ubuntu 10.10

Welcome to Ubuntu!
 * Documentation:  https://help.ubuntu.com/

New release 'natty' available.
Run 'do-release-upgrade' to upgrade to it.


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

minerva@minerva:~$
となって、無事にsshで接続成功。

RTX1200を用いた場合の、SSLを使用してのメールの送受信

RTX1200を使い始めた頃のことである。何故か知らないがメールの送受信が出来なくなった。

SSLを利用したメールの送受信である。

メーラーの設定を変更したわけではないのでルータの設定だと目星をつけたところまでは良かったのだが、

configファイルを見ても、どこの設定が不足しているかが分からない。

仕方ないので、YAMAHAにconfigファイルを送ったところ、下記の2行の設定が反映されていないという

指摘を受けた。
ip filter dynamic 200098 * * tcp
ip filter dynamic 200099 * * udp

設定がされている以上、当然反映されているものだと思っていたのだが、勝手な思い込みだった。

という訳で

ip pp secure filter out 200013 200020 200021 200022 200023 200024 200025 20002
6 200027 200099 dynamic 200080 200081 200082 200083 200084

となっていた設定を下記のように変更して、

ip pp secure filter out 200013 200020 200021 200022 200023 200024 200025 20002
6 200027 200099 dynamic 200080 200081 200082 200083 200084 200098 200099


再度メールの送受信を試したところ、無事に成功。

C++のコンパイラ

IntelのFortranコンパイラをubuntuにインストールして使用してみようとしたところ、g++が入っていないという警告を受けた。
C言語のコンパイラであるgccが入っているのだから、C++言語のコンパイラも当然入っていると思っていたのだが、考えが甘かった。
先入観を持って物事に臨んではいけないと分かっていたつもりだったが、実行できなかったということは本当に分かっていなかったという事だろう。気をつけないといけない。

RTX1200

Linuxとは全く関係ないが、最近、ルータを購入した。

ヤマハRTX1200である。早速ファームウェアのアップデートを行う。

説明書を読んだところ、usbにデータを保存してRTX1200に保存すればよいらしい。

(最初、某サイトでusbの先頭領域にデータを書き込むという記載があったために、

ddコマンドで書き込むというとんでもない馬鹿をやらかした。

今考えると、あり得ないミスだ・・・。)

というわけで、単純にダウンロード後、usbに保存してRTX1200に接続する。

簡単にファームウェアのアップデートに成功。必要時間数秒間か?

まさかこんな簡単にアップデート出来るとは思わなかった・・・。

 今まで使用していたルータ(XR-440/C)と比較すると明らかに通信速度が上がった。

94Mbpsとか何かの間違いだろうが、まぁ、気分が良いデータだった。

(以前のルータ、100Mbps対応ルータだったせいもあるかもしれないが。)

おまけにL2 switchまで、HP ProCurve 1410-24G Switch(J9561A#ACF)

(http://h50146.www5.hp.com/products/networks/procurve/products/switches/switch1410series/overview.html)

なんていうものに変更したし。

Ciscoの製品の購入も検討したが、流石に10万以上の製品を遊びのために購入する気にはならなかった・・・。

scpコマンドでファイルコピー

athena@athena:~$ scp minerva@192.168.0.30:/home/minerva/firefox /home/athena/
ssh: connect to host 192.168.0.30 port 22: Connection refused

ssh接続が拒否されている。認証の問題か?

そういえば、鍵をいれていない。

それどころか、鍵の問題以前にopenssh-serverをいれていない。

というわけで、openssh-serverをinstall

athena@athena:~$ sudo aptitude install openssh-server
[sudo] password for athena:
以下の新規パッケージがインストールされます:
openssh-server
0 個のパッケージを更新、 1 個を新たにインストール、 0 個を削除予定、4 個が更新されていない。
302kB のアーカイブを取得する必要があります。 展開後に 819kB のディスク領域が新たに消費されます。
取得:1 http://jp.archive.ubuntu.com/ubuntu/ maverick-updates/main openssh-server i386 1:5.5p1-4ubuntu5 [302kB]
302kB を 0秒 秒でダウンロードしました (558kB/s)
パッケージを事前設定しています ...
未選択パッケージ openssh-server を選択しています。
(データベースを読み込んでいます ... 現在 138687 個のファイルとディレクトリがインストールされています。)
(.../openssh-server_1%3a5.5p1-4ubuntu5_i386.deb から) openssh-server を展開しています...
ureadahead のトリガを処理しています ...
ureadahead will be reprofiled on next reboot
ufw のトリガを処理しています ...
man-db のトリガを処理しています ...
openssh-server (1:5.5p1-4ubuntu5) を設定しています ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
* Stopping OpenBSD Secure Shell server sshd [ OK ]
ssh start/running, process 2287

athena@athena:~$ scp minerva@192.168.0.30:/home/minerva/firefox /home/athena/
The authenticity of host '192.168.0.30 (192.168.0.30)' can't be established.
RSA key fingerprint is bb:48:f5:bd:99:28:76:31:9d:54:99:89:6f:97:42:15.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.30' (RSA) to the list of known hosts.
minerva@192.168.0.30's password:
scp: /home/minerva/firefox: No such file or directory
athena@athena:~$ scp minerva@192.168.0.30:/home/minerva/download/firefox /home/athena/
minerva@192.168.0.30's password:
firefox 100% 596KB 596.2KB/s 00:00

パスワードを入力し、無事にコピー完了。

CD-R/RWにデータを書き込む

CD-R/RWにデータを書き込みたかったので、検索したところ、



【 CD-R/RWにデータを書き込む 】

を発見。

使用しているCD-RWのデバイス番号を調べる必要があるため、

cdrecord -scanbus

を実行する。


ubuntu@ubuntu:~$ cdrecord -scanbus

scsibus4:
4,0,0 400) 'PIONEER ' 'DVD-ROM DVD-120 ' '1.23' Removable CD-ROM
4,1,0 401) *
4,2,0 402) *
4,3,0 403) *
4,4,0 404) *
4,5,0 405) *
4,6,0 406) *
4,7,0 407) *
scsibus7:
7,0,0 700) 'Optiarc ' 'DVD RW AD-7173A ' '1-2E' Removable CD-ROM
7,1,0 701) *
7,2,0 702) *
7,3,0 703) *
7,4,0 704) *
7,5,0 705) *
7,6,0 706) *
7,7,0 707) *


との表示が出たため、

デバイス番号「7,0,0」にDVD-RWドライブが接続されていることが判明。

必要最低限な事が分かったため、早速書き込む。

ubuntu@ubuntu:~/download$ cdrecord dev=7,0,0 speed=24 -v -eject -data mbm039.iso
wodim: No write mode specified.
wodim: Assuming -tao mode.
wodim: Future versions of wodim may have different drive dependent defaults.
TOC Type: 1 = CD-ROM
wodim: Operation not permitted. Warning: Cannot raise RLIMIT_MEMLOCK limits.
scsidev: '7,0,0'
scsibus: 7 target: 0 lun: 0
WARNING: the deprecated pseudo SCSI syntax found as device specification.
Support for that may cease in the future versions of wodim. For now,
the device will be mapped to a block device file where possible.
Run "wodim --devices" for details.
Linux sg driver version: 3.5.27
Wodim version: 1.1.10
SCSI buffer size: 64512
Device type : Removable CD-ROM
Version : 0
Response Format: 2
Capabilities :
Vendor_info : 'Optiarc '
Identification : 'DVD RW AD-7173A '
Revision : '1-2E'
Device seems to be: Generic mmc2 DVD-R/DVD-RW.
Current: 0x0009 (CD-R)
Profile: 0x002B (DVD+R/DL)
Profile: 0x001B (DVD+R)
Profile: 0x001A (DVD+RW)
Profile: 0x0016 (DVD-R/DL layer jump recording)
Profile: 0x0015 (DVD-R/DL sequential recording)
Profile: 0x0014 (DVD-RW sequential recording)
Profile: 0x0013 (DVD-RW restricted overwrite)
Profile: 0x0012 (DVD-RAM)
Profile: 0x0011 (DVD-R sequential recording)
Profile: 0x0010 (DVD-ROM)
Profile: 0x000A (CD-RW)
Profile: 0x0009 (CD-R) (current)
Profile: 0x0008 (CD-ROM) (current)
Profile: 0x0002 (Removable disk)
Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr).
Driver flags : MMC-3 SWABAUDIO BURNFREE
Supported modes: TAO PACKET SAO SAO/R96R RAW/R96R
Drive buf size : 890880 = 870 KB
Beginning DMA speed test. Set CDR_NODMATEST environment variable if device
communication breaks or freezes immediately after that.
FIFO size : 12582912 = 12288 KB
Track 01: data 2 MB
Total size: 2 MB (00:14.98) = 1124 sectors
Lout start: 2 MB (00:16/74) = 1124 sectors
Current Secsize: 2048
ATIP info from disk:
Indicated writing power: 4
Is not unrestricted
Is not erasable
Disk sub type: Medium Type A, high Beta category (A+) (3)
ATIP start of lead in: -11849 (97:24/01)
ATIP start of lead out: 359847 (79:59/72)
Disk type: Long strategy type (Cyanine, AZO or similar)
Manuf. index: 25
Manufacturer: Taiyo Yuden Company Limited
Blocks total: 359847 Blocks current: 359847 Blocks remaining: 358723
Speed set to 4234 KB/s
Starting to write CD/DVD at speed 24.0 in real TAO mode for single session.
Last chance to quit, starting real write in 0 seconds. Operation starts.
Waiting for reader process to fill input buffer ... input buffer ready.
Performing OPC...
Starting new track at sector: 0
Track 01: 2 of 2 MB written (fifo 100%) [buf 100%] 5.6x.
Track 01: Total bytes read/written: 2297856/2297856 (1122 sectors).
Writing time: 20.469s
Average write speed 3.9x.
Min drive buffer fill was 100%
Fixating...
Fixating time: 26.060s
BURN-Free was never needed.
wodim: fifo had 37 puts and 37 gets.
wodim: fifo was 0 times empty and 0 times full, min fill was 100%.
ubuntu@ubuntu:~/download$
動作確認したところ、きちんと焼けていた。ブランクCDを無駄にしないで済み良かった・・・。

CPUが32bitか64bitを調べるには?

CPUが32bitか64bitを調べるには、
uname -m
とやれば良い。
i686と出れば、64bitである。
もっと細かい情報が知りたい場合、
cat /proc/cpuinfo
をやれば良い。

CD(DVD)イメージを抽出するには

ddコマンドを用いれば良い。

CD(DVD)イメージをcdrom.isoという名前で抽出する場合、

sudo dd if=/dev/sr0 of=~/cdrom.iso

とやれば良い。