Mac App Store、さくらのレンタルサーバ用アクセス解析プログラム Sakura Version 1.0 公開

随分遅れましたが、新年明けましておめでとうございます。今年も宜しくお願いします。
Mac App Store が始まりましたね。私は iWorks を持っていないので、とりあえず

Numbers
カテゴリ:仕事効率化
\2300
http://itunes.apple.com/jp/app/numbers/id409203825?mt=12

を購入しました。Pages と Keynote については、購入するか悩んでいます。

前回、紹介した ‘さくらのレンタルサーバアクセス解析プログラム Sakura Version 1.0 ‘ を

さくらのレンタルサーバアクセス解析プログラム Sakura Version 1.0
Programmed by KOYAMA Yoshiaki
概要
ターミナル上で動作するスクリプト。
ファイル名を指定しなくても、さくらのレンタルサーバから現在最新のアクセスログ
ファイルをダウンロードし、アクセス解析を表示する。
Yoshiaki's HomePage
http://kyoshiaki.sakura.ne.jp/osx/index.html

で公開します。あまりアクセス数の多いサイトにはむかないかもしれません。良かったらダウンロードしてください。

'さくらインターネットのレンタルサーバー スタンダード' と ssh

以前、漫画家のすがやみつるさんが

プログラミングができなくても作れるTwitter botの作り方
http://pha22.net/twitterbot/

を利用して Twitter bot (EasyBotter) を作成したと発言されていました。

COOL ONLINE
http://www.cool.ne.jp/
PHP version 4.3.2

私は COOL ONLINE 正規会員登録しています。COOL ONLINE の PHP は version 4.3.2 のようです。Twitter bot (EasyBotter) では PHP 5 以上が必要です。

低額の料金で VPS が利用できる ‘さくらの VPS’ に興味を持っていたので

さくらインターネット|価値あるサービスと満足を提供するデータセンター
http://www.sakura.ad.jp/

で資料を読んでいました。 たまたま ‘さくらの VPS’ ではなく ‘さくらのレンタルサーバー’ も試しに調べてみると ssh、cron が使え、PHP 5.2.14 と記載されていました。アクセス解析も付いています。

プログラミングができなくても作れるTwitter botの作り方
http://pha22.net/twitterbot/

Twitter bot (EasyBotter) を試すために ‘さくらインターネットレンタルサーバー スタンダード’ に移転することにしました。 ssh を利用してみたかったことも動機の一つです。

Yoshiaki's HomePage
http://koyama-.cool.ne.jp/

上記ページを下記ページに移転します。上の COOL ONLINE ホームページは、来年の 2月頃に終了予定です。もう少し早まるかもしれません。

Yoshiaki's HomePage
http://kyoshiaki.sakura.ne.jp/osx/index.html

Twitter bot (EasyBotter) は何の問題なくインストールすることができました。新規に Twitter bot (EasyBotter) 用の Twitter アカウント KYoshiakiBot を作成し、

Create cool applications! | dev.twitter.com
http://dev.twitter.com/

アプリケーション名を YKEasyBotter で登録しました。上部の Your apps をクリックして

Twitter Applications | dev.twitter.com
http://dev.twitter.com/apps

現在登録されているアプリケーション一覧を表示し、YKEasyBotter をクリックすると Consumer key、Consumer secret を確認できます。Access Token を見つけるのに少し苦労しました。結局、Consumer key などが表示されているページの右側にある My Access Token をクリックすることで Access Token (oauth_token)、Access Token Secret (oauth_token_secret) を見つけることができました。

残念ながら、私が確認したかった OAuth 認証の仕組みではありませんでした。Twitterbot (EasyBotter) 自体は何の問題もなく動作しました。’さくらインターネットレンタルサーバー スタンダード’で は cron も使うことができます。

さくらインターネットレンタルサーバー スタンダード’ には Webalizer によるアクセス解析が付いてきます。しかし、COOL ONLINE で

COOL ONLINE
http://www.cool.ne.jp/
Yoshiaki's HomePage
http://koyama-.cool.ne.jp/
高機能アクセス解析CGI Professional版 - futomi's CGI Cafe
http://www.futomi.com/library/accp.html

利用していたシェアウェアの ‘高機能アクセス解析CGI Professional版 – futomi’s CGI Cafe’ と比べると非力です。しかし、’さくらインターネットレンタルサーバー スタンダード’ では、一日ごとのアクセスをログファイルに作成してくれます。そのログファイルをコマンドを実行すると自動的にダウンロードし、解析して表示する Python スクリプトとシェルスクリプトを作成しました。いずれ公開したいと思います。


さくらインターネットレンタルサーバー スタンダード’ では ssh も利用できます。

‘さくらの VPS’ のために Kindle 版の Pro Linux System Administration 本を購入したのですが、ssh の使用方法も解説されていました。良書です。まだ、半分ほどしか読んでいませんが!

Mac OS X Snow Leopard (バージョン 10.6.5 ビルド 10H574) 上の ‘ターミナル’ と Ubuntu 10.10 ‘Terminal’ 上での簡単な ssh の利用方法解説したいと思います。間違いもあるかもしれません。

SSH の仕組みを利用するコマンドは

  • ssh username@remotehost
  • scp foo.txt username@remotehost:/home/username/www/
  • sftp username@remotehost

などがあります。

ただし、アカウント: username、初期ドメイン: remotehost は

会員メニュートップ
https://secure.sakura.ad.jp/menu/top/

の ‘契約情報’/’契約サービスの確認’/’サーバ設定’ をクリックして ‘さくらインターネットサーバコントロールパネル’ 上部の ‘お客様情報’ で確認してください。

さくらインターネットサーバコントロールパネル
https://secure.sakura.ad.jp/rscontrol/rs/

以下の説明で、アカウント: username、初期ドメイン: remotehost を自分の環境に合わせて変更してください。また、ssh で使用するパスワードは、さくらのウェブ上の会員 ID でログインするパスワードではないので注意してください。

  • ssh username@remotehost
  • scp foo.txt username@remotehost:/home/username/www/
  • sftp username@remotehost

上のコマンドを何も設定せずに実行するとパスワードを尋ねられますが、RSA 公開鍵暗号による認証を利用するとパスワードやパスフレーズ (passphrase) : (秘密鍵用のパスワード) を入力せずにログインすることができます。

sshRSA 公開鍵暗号による認証を利用するには

1. コマンド ssh-keygen を使って公開鍵、秘密鍵を作成する。パスフレーズ (passphrase) : (秘密鍵用のパスワード) は、ssh-agent やキーチェーンで登録できるので安全のためにできるだけ入力してください。
2. コマンド ssh-copy-id を使って ~./ssh フォルダのファイル authorized_keys に公開鍵を追加。Mac OS X 上では、コマンド ssh-copy-id がないので手動でコピーする必要があります。
3. コマンド ssh-agent、 eval `ssh-agent`、 ssh-add を使って パスフレーズ (passphrase) : (秘密鍵用のパスワード) を登録。Mac OS X の場合、キーチェーンが パスフレーズ (passphrase)  : (秘密鍵用のパスワード) を管理してくれます。

おおまかに上の3つの手順で設定します。

1. Mac OS X Snow Leopard (バージョン 10.6.5 ビルド 10H574) 上の ‘ターミナル’ 上での ssh 設定

1-1. Mac OS X 上の ‘ターミナル’ で、コマンド ssh-keygen -t rsa -b 2048 で公開鍵、秘密鍵を作成。パスフレーズ (passphrase) : (秘密鍵用のパスワード) も安全のためできるだけ登録してください。

~ $ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xxxx/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/xxxx/.ssh/id_rsa.
Your public key has been saved in /Users/xxxx/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx xxxx@xxxxx-xxxxx-xx-xxxx-x.local
The key's randomart image is:
+--[ RSA 2048]----+
|         .F++oo..|
|          xxx+ . |
|           =+.. x|
|       . . .+. xx|
|        G .  .xx |
|              ...|
|               ..|
|               ..|
|              .. |
+-----------------+
~ $ 

1-2. ~/.ssh フォルダにファイル id_rsa (公開鍵) 、d_rsa.pub (秘密鍵) が作成されているのを確認。

~ $ cd .ssh
~/.ssh $ ls
id_rsa		id_rsa.pub	known_hosts

1-3. リモートホスト (さくら側) に ファイル id_rsa.pub をファイル authorized_keys としてコピー。パスワードを尋ねられるので入力してください。

~/ $ cd .ssh
~/.ssh $ scp id_rsa.pub username@remotehost:/home/username/.ssh/authorized_keys
username@remotehost's password:
id_rsa.pub                                    100%  422     0.4KB/s   00:00    

1-4 最初にコマンド ssh を実行するとパスフレーズを尋ねられます。パスフレーズ (passphrase) : (秘密鍵用のパスワード) を入力して ‘パスワードをキーチェーンに保存’ にチェックを入れてください。これで ssh、scp、sftp を実行しても パスフレーズ (passphrase) : (秘密鍵用のパスワード) を尋ねられることはありません。

~/.ssh $ ssh usernamei@useraname.sakura.ne.jp
Identity added: /Users/yoshiaki/.ssh/id_rsa (/Users/xxxx/.ssh/id_rsa)
Last login: Sun xxx  5 xx:43:14 2010 from xx.xx.xx.xx
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California.  All rights reserved.
FreeBSD 7.1-RELEASE-p15 (SAKURA11S) #10: Tue Nov 16 09:48:35 JST 2010
Welcome to FreeBSD!
%exit
logout
Connection to remotehost closed.


上図の赤枠部分より、秘密鍵のパスフレーズがアプリケーション ‘キーチェーンアクセス’ で 保存されているのが確認できます。

1-5 リモートホスト (さくら側) のファイル authorized_keys のパーミッションは 600 にしてください。

~ $ ssh username@remotehost
Last login: xxx xxx 00 xx:32:00 2010 from xx.xx.xx.xx
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California.  All rights reserved.
FreeBSD 7.1-RELEASE-p15 (SAKURA11S) #10: Tue xxx 16 09:48:35 JST 2010
Welcome to FreeBSD!
%cd .ssh
%ls
authorized_keys
%chmod 600 authorized_keys
%ls -alF
total 10
drwx------   x xxxx  xxxx  512 xxx 0 16:54 ./
drwx---r-x   xx xxxx  xxxx  512 xxx 00 19:53 ../
-rw-------   xx xxxx xxxx  819 xxx  0 19:50 authorized_keys
%exit
logout
Connection to remotehost closed.
~ $ 

2. Ubuntu 10.10 ‘Terminal’ 上での簡単な ssh の設定方法

2-1. Ubuntu 上の ‘Terminal’ で、コマンド ssh-keygen -t rsa -b 2048 で公開鍵、秘密鍵を作成。パスフレーズ (passphrase) : (秘密鍵用のパスワード) も安全のため登録しておく。

ubuntu:~$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xxxx/.ssh/id_rsa):
Created directory '/home/xxxx/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/xxxx/.ssh/id_rsa.
Your public key has been saved in /home/xxxx/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx xxxxi@ubuntu
The key's randomart image is:
+--[ RSA 2048]----+
|        ...      |
|       . x       |
|      . . .      |
|       x .       |
|      x x x      |
|     x x x .     |
|    x.x . .      |
|     --x .       |
|    .x--.        |
+-----------------+

2-2. ~/.ssh フォルダにファイル id_rsa (公開鍵) 、d_rsa.pub (秘密鍵) が作成されているのを確認。

ubuntu:~$ cd .ssh
ubuntu:~/.ssh$ ls
id_rsa  id_rsa.pub  known_hosts
ubuntu:~/.ssh$ 

2-3. コマンド ssh-copy-id を使って、リモートホスト (さくら側) に ファイル id_rsa.pub をファイル authorized_keys に追加。パスワードを尋ねられるので入力してください。

ubuntu:~$ ssh-copy-id username@remotehost
The authenticity of host 'remotehost (xx.xx.xx.xx)' can't be established.
DSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'remotehost,xx.xx.xx.xx' (DSA) to the list of known hosts.
username@remotehost's password:
Now try logging into the machine, with "ssh 'username@remotehost'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
ubuntu:~$ 

2-4. 試しに ssh で、リモートホスト (さくら側) にログインしてみると、パスフレーズ (passphrase) : (秘密鍵用のパスワード) を尋ねてきます。

ubuntu:~$ ssh username@remotehost
Enter passphrase for key '/home/xxxx/.ssh/id_rsa':
Last login: xxx xxx  5 xx:33:26 2010 from xx.xx.xx.xx
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California.  All rights reserved.
FreeBSD 7.1-RELEASE-p15 (SAKURA11S) #10: Tue Nov 16 09:48:35 JST 2010
Welcome to FreeBSD!
%exit
logout
Connection to remotehost closed.
ubuntu:~$ 

2-5 コマンド ssh-agent で環境変数を確認。

ubuntu:~$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-TlhOE20539/agent.20539; export SSH_AUTH_SOCK;
SSH_AGENT_PID=20540; export SSH_AGENT_PID;
echo Agent pid 20540;

2-6 ssh-agent -k で停止。

ubuntu:~$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 1465 killed;

2-7 コマンド eval `ssh-agent` を実行して、環境変数を設定。文字 ` と ‘ の違いに注意してください。

ubuntu:~$ eval `ssh-agent`
Agent pid 20550
ubuntu:~$  

2-8 ssh-add を使ってパスフレーズ (passphrase) : (秘密鍵用のパスワード) を追加。

ubuntu:~$ ssh-add
Enter passphrase for /home/xxxx/.ssh/id_rsa:
Identity added: /home/xxxx/.ssh/id_rsa (/home/yoshiaki/.ssh/id_rsa)
ubuntu:~$

2.9 これで ssh、scp、sftp でログインしても パスフレーズ (passphrase) : (秘密鍵用のパスワード) を尋ねられません。

ubuntu:~$ ssh username@remotehost
Last login: Mon xxx  x xx:53:59 2010 from xx.xx.xx.xx
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California.  All rights reserved.
FreeBSD 7.1-RELEASE-p15 (SAKURA11S) #10: Tue Nov 16 09:48:35 JST 2010
Welcome to FreeBSD!
%

2-10 リモートホスト (さくら側) のファイル authorized_keys のパーミッションは 600 にしてください。

~ $ ssh username@remotehost
Last login: xxx xxx 00 xx:32:00 2010 from xx.xx.xx.xx
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California.  All rights reserved.
FreeBSD 7.1-RELEASE-p15 (SAKURA11S) #10: Tue Nov 16 09:48:35 JST 2010
Welcome to FreeBSD!
%cd
%cd .ssh
%ls
authorized_keys
%chmod 600 authorized_keys
%ls -alF
total 10
drwx------   x xxxx  xxxx  512 xxx 0 16:54 ./
drwx---r-x   xx xxxx  xxxx  512 xxx 00 19:53 ../
-rw-------   xx xxxx xxxx  819 xxx  0 19:50 authorized_keys
%exit
logout
Connection to remotehost closed.
~ $ 

Apple、日本のiTunes Storeで映画の提供を開始、The Beatles の楽曲を販売開始、 IC レコーダー ICD-AX80、VMware 上の Windows XP ハードディスク容量拡張

Apple、日本のiTunes Storeで映画の提供を開始
http://www.apple.com/jp/news/2010/nov/11itunesjp.html

iTunes Store で映画の提供が開始され、Apple TV も発売されました。

家のテレビのアンテナが壊れたので、テレビもデジタルテレビに買い替えました。エコポイントが今月一杯で終了するので、家電量販店では駆け込み需要で大変なようです。今月中にはテレビが到着するとは思うんですが!Apple TV も購入してみようかなと思っています。

明日、いつもと同じ一日が、
忘れられない一日になります。
iTunesからの特別な発表を、明日ここで行います。お見逃しなく。

日本時間 11月17日午前 0 時に発表があると上のように告知されたので、その時間にアップルのサイトにアクセスしたのですが、なかなか表示されませんでした。試しに iTunes を起動してみました。すると The Beatles の楽曲が販売されていました。
年齢がばれてしまうかもしれませんが!The Beatls の思い出は、小中学校の時、下校時間に The Beatls の Yesterday が鳴っていたり、ひらけ! ポンキッキで Yellow Submarine が放送されていたことです。

アップル - iTunesThe Beatlesを。
http://www.apple.com/jp/the-beatles/

上のサイトで CM やライブを見ました。何か買ってみようかな!

話は変わって、父が SONY の IC レコーダー ICD-AX80 を買ってきました。それで、音声を編集して欲しいと頼まれました。

IC レコーダーのソフト Degital Voice Editor 3 は Windows 上でしか動作しないので、VMware Fusion 上の Windows XP にインストールしてみました。問題なく、動作します。

IC レコーダー ICD-AX80 を iMac の USB に繋ぐと Windows に接続するか、Mac に接続するか尋ねてくるので、Windows を選択します。

その後、Windows XP 上の Degital Voice Editor 3 を起動して、IC レコーダー上のデータを右クリックして ‘パソコンに保存’ を選び、Windows XP 上に MP3 で保存します。そのファイルを iMac のデスクトップ上にドラッグ・ドロップして iMac 上にコピーしました。

音声データの編集に何か良いソフトがないか、Google で検索してみると GarageBand が使えるようです。それで

GarageBandでMP3の編集 - ★ B. T. T. P ★
http://d.hatena.ne.jp/sohei/20080921/p1
http://anokoro.xrea.jp/etc/GarageBand-mp3.swf

を参考に編集してみました。そんな難しいことをしたいわけではありません。

簡単に説明すると GarageBand で新規プロジェクト Piano を選び、トラックを削除して、IC レコーダーからコピーした MP3 ファイルを GarageBand 上にドロップします。後は、編集メニューの分割と削除を使って音声データを編集しました。できあがったら、メニュー ’共有/iTunes に曲を送信…’ を選び、iTunes 上に MP3 でコピーします。iTunes ででき上がった曲を右クリック ‘Finder で表示’ を選び、そのファイルを VMware Fusion 上の Windows XP デスクトップにドラッグ・ドロップします。ドロップした MP3 ファイルを Degital Voice Editor 3 で使用するディレクトリに移動し、IC レコーダー ICD-AX80 に戻しました。

Windows XP 上にいろいろソフトをインストールしたり、音声データをたくさん作成したため、Windows XP 上のハードディスク容量 20GB では足りなくなってきました。それで 40 GB に増やしてみることにしました。

まず、VMware Fusion 上のヘルプを参照してみると

ヘルプ
仮想マシンの設定/
仮想ハード ディスクの管理
ハード ディスクのサイズ変更
Windows パーティションのサイズ変更

VMware Fusion仮想マシンのハードディスク設定を変更した後、それぞれの OS 側で変更する必要があるようです。

Windows 7 の方法は記載されています。

注意
Windows XP の場合は、サードパーティのハード ドライブ パーティション管理ユーティリティを使用する必要があります。インターネットで入手できる無料製品や市販製品があります。

しかし、Windows XP では上のようにサードパーティのソフトが必要だと書いてあります。

それで、本家の解説を見てみると

VMware Virtualization Software for Desktops, Servers & Virtual Machines for Public and Private Cloud Solutions
http://www.vmware.com/
Support & Downloads
VMware KB: Resizing a virtual disk in VMware Fusion
http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=1020778&sliceId=1&docTypeID=DT_KB_1_1&dialogID=121612964&stateId=1%200%20121614987
VMware KB: Increasing the size of a disk partition
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1004071

サードパーティソフトが紹介されています。ただし、すべて有料ソフトです。

Google で検索してみると

GParted -- Live CD/USB/PXE/HD
http://gparted.sourceforge.net/livecd.php

を利用すれば良いようです。

VMware上のWindows XPのシステムディスクを拡張し、容量を増やす
http://www.padmacolors.org/entry/20100224/1923/
AQUA///BLUE-記憶と記録- » VMware fusionのVMパーテション変更
http://www.skunkworld.org/weblog/?p=1718

上記ページを参考にパーティーションを拡大してみました。残念ながら、マウスの反応がおかしいので、Tab キー、カーソルキー、容量のところで、数字を直接入力して実行しました。