plnet.jpをだいぶ修正しました。

専用サーバになってinnoDBが使えるようになってトランザクションやFK制約、ON DELETE CASCADEが使えるのでテーブル構成やロジックを一から直しました。

今までエントリーが重複してたり、付けてないタグが付いてたりしていまいち信頼性が低かったんですが、innodb化と一緒にガチガチ目指してみました。

mixi_support

それとmixiに対応しました。ソース毎のRSSも吐いているので“全体に公開”にしていれば手軽にmixiのRSSも利用できます。

・・・。

連休中にコードばっか書いてるのバレバレかよ。

グーグル・アマゾン化する社会

オハイオ州ダブリンで制定されたからダブリンコアって言うのか…。(そういう内容の本じゃありません)

503が出まくっていたplnet.jpを新しい専用サーバへ移行しました。

はえー、はえー。

これで止められまくりのだったcronも動かせます。

さくらインターネットの500円のヤツ、安くてかなり便利ですがアクセス増えるとやっぱり厳しいです。503ってことはプログラムの負荷というより単に共有してるApacheのMaxClients、MaxRequestsPerChildかなと思います。

1万PV/1日ぐらいで503出初めて、2万PV/1日以上はまともに使えないって感じなのでニート(俺)以外ははじめっから専用サーバ借りたほうが良さそうです。あたりまえか。

PHP4でDB系のテストがやりたくてrake db:fixtures:load的にテーブル毎のファイルからDBへロード/ダンプするクラスを書いてみました。

<?php
require_once 'INILoader.php';
dump_ini('/path/to/fixtures', 'mysql://user:pass@localhost/dbname');
?>

(magpieみたいにグローバルにいい加減なファサード作っちゃうquick & dirtyさ加減)

こんな感じで書くと、

% cat fixtures/member.ini
[member1]
id = "1" 
design_id = "1" 
account = "komagata" 
password = "aaa" 
email = "komagata@p0t.jp" 
createdtime = "2006-08-12 15:36:51" 
[member2]
id = "2" 
design_id = "2" 
account = "tom" 
password = "iii" 
email = "tom@gmail.com" 
createdtime = "2006-08-12 11:36:51" 
[member3]
id = "3" 
design_id = "3" 
account = "bob" 
password = "uuu" 
email = "bob@gmail.com" 
createdtime = "2006-08-12 12:36:51"

こんな感じの中身を指定したディレクトリに“テーブル名.ini”で吐く。yamlだとまんま過ぎなので何故かiniです。

<?php
require_once 'INILoader.php';
load_ini('/path/to/fixtures', 'mysql://user:pass@localhost/dbname');
?>

こう書くと逆にiniファイルを読んでテーブルにロードする。

以下コード。(さっとパッケージ化できる人になりたい)

<?php
require_once 'DB.php';

class INILoader
{
    var $fixtures_dir;
    var $dsn;
    var $key_check;
    var $db;

    function INILoader($fixtures_dir, $dsn, $key_check = true)
    {
        $this->fixtures_dir = $fixtures_dir;
        $this->dsn = $dsn;
        $this->key_check = $key_check;
        $this->db =& DB::connect($dsn);
        $this->db->autoCommit(false);
        $this->db->setFetchMode(DB_FETCHMODE_ASSOC);
    }

    function load($name = null)
    {
        if (is_null($name)) {
            $this->db->query('BEGIN');
            $this->_truncate_all();
            $this->_load_all();
            $this->db->commit();
        } else {
            $this->db->query('BEGIN');
            $this->_truncate($name);
            $this->_load($name);
            $this->db->commit();
        }
    }

    function dump($name = null)
    {
        if (is_null($name)) {
            $this->_remove_all();
            $this->_dump_all();
        } else {
            $this->_remove($name);
            $this->_dump($name);
        }
    }

    function _load_all()
    {
        if (!$this->key_check and preg_match("/^mysql/", $this->dsn)) {
            $this->db->query('SET FOREIGN_KEY_CHECKS = 0');
        }

        foreach ($this->_get_ini_files() as $file) {
            list($name, $ext) = split("\.", $file);
            $this->_load($name);
        }

        if (!$this->key_check and preg_match("/^mysql/", $this->dsn)) {
            $this->db->query('SET FOREIGN_KEY_CHECKS = 1');
        }
    }

    function _truncate_all()
    {
        foreach ($this->_get_ini_files() as $file) {
            list($name, $ext) = split("\.", $file);
            $this->_truncate($name);
        }
    }

    function _load($name)
    {
        echo "Load table {$name}... ";
        $data = parse_ini_file("{$this->fixtures_dir}/{$name}.ini", true);
        foreach ($data as $fields) {
            if (DB::isError($res = $this->db->autoExecute($name, $fields))) {
                $this->db->rollback();
                echo "failed\n";
                trigger_error('INILoader::_load(): Failed to load. '
                .$res->toString(), E_USER_ERROR);
            }
        }
        echo "succeed\n";
    }

    function _truncate($name)
    {
        echo "Truncate table {$name}... ";
        $sql = "TRUNCATE $name";
        if (DB::isError($res = $this->db->query($sql))) {
            $this->db->rollback();
            echo "failed\n";
            trigger_error('INILoader::_truncate(): Failed to truncate. '
            .$res->toString(), E_USER_ERROR);
        }
        echo "succeed\n";
    }

    function _dump_all()
    {
        foreach ($this->db->getTables() as $table) {
            $this->_dump($table);
        }
    }

    function _remove_all()
    {
        foreach ($this->db->getTables() as $table) {
            $this->_remove($table);
        }
    }

    function _dump($name)
    {
        echo "Dump table {$name}... ";
        $file = "{$this->fixtures_dir}/{$name}.ini";
        $handle = fopen($file, 'a');
        $sql = "SELECT * FROM $name";
        foreach ($this->db->getAll($sql) as $index => $fields) {
            $line = "[{$name}".++$index."]\n";
            foreach ($fields as $key => $value) {
                $line .= "{$key} = \"{$value}\"\n";
            }

            if (!fwrite($handle, $line)) {
                trigger_error("INILoader::dump(): Failed to write $file",
                E_USER_ERROR);
            }
        }
        fclose($handle);
        echo "succeed\n";
    }

    function _remove($name)
    {
        echo "Remove file {$name}.ini ... ";
        unlink("{$this->fixtures_dir}/{$name}.ini");
        echo "succeed\n";
    }

    function _get_ini_files()
    {
        $files = array();
        $d = dir($this->fixtures_dir);
        while ($entry = $d->read()) {
            if (preg_match("/\.ini$/", $entry)) {
                $files[] = $entry;
            }
        }
        $d->close();
        return $files;
    }
}

function load_ini($fixtures_dir, $dsn, $key_check = false)
{
    $loader =& new INILoader($fixtures_dir, $dsn, $key_check);
    $loader->load();
}

function dump_ini($fixtures_dir, $dsn)
{
    $loader =& new INILoader($fixtures_dir, $dsn);
    $loader->dump();
}
?>

パソコンに関しては“なるべくデフォルト派”(あまりソフトを入れない)の俺です。結構多いと思われますが、デフォルト派のランチャーといえばやはり、

shell

“ファイル名を指定して実行”(以下ファ実)

コレ。

そして、

quick_start

“クイック起動”

コレですよ。

ファ実といえば、“ウィンドウズキー + R”。

「最近のThinkPadは良くなった。」

とはあるデフォルト派の言葉です。(ウィンドウズキーが付いた。)

こういうエントリが話題になるほど便利で便利でしょうがねえファ実ですが、ファイル名の補完ができないのが難点。

そこで、「補完が効くヤツを使おう」ではなく、「補完が効かないなら短い名前を付ければ良い」と考えてしまうのがデフォルト派。

bin

PATHを通したフォルダに短い名前のショートカットを沢山置いておけっ・・・・・・・・・!!!

UbuntuとWindowsをデュアルブートで使ったりしてたんですが、開発に関してWindowsで不便だと感じてた点がこれ。

「開発環境に入りたい時に、“PuttyをWクリック → セッション名をWクリック”という2アクションが必要。」

UbuntuやMacならTerminal立ち上げてすぐコマンド打ち始められるじゃないすか。不便じゃないですか。

…。

「何を言ってるんだこいつは。別に不便じゃない」という方、ありがとうございます。話が終わってしまいます。

やり方は簡単です。

shell_property

こういうショートカットを作っておけば1クリでこうです。

shell_putty

Using PuTTY

In order to start an existing saved session called sessionname, use the -load option (described in section 3.7.3.1).

putty.exe -load ””session name”“

puttyは—helpとかやっても何も出ないんですが、-loadでセッション名を指定出来るんだそうです。パスフレーズ無しの鍵(NATなら外から入れないので問題ないと思う)でcoLinuxに入るセッションを作って、指定すればまるでGNOME Terminalでローカルの開発環境を使ってるみたいになります。

shell_icon

ついでにさっきの画像の様にショートカットキーを設定したショートカットをデスクトップに置けばマウス無しで開けて便利です。

p0t: Webサービスのライセンス

でもブラウザがプラットフォームになると、Webサービスの利用規約とWeb APIの利用規約がGPL、LGPLの変わりになってどうでもよくなっちゃうのかな。

それぞれ標準のライセンスがあれば簡単なのに。ちょっとググったけど出てこなかった。

この問題。

【レポート】European Open Source Convention 2006 – Tim O’Reilly氏、Open Source 2.0を語る (2) Web 2.0時代のライセンス (MYCOMジャーナル)

「インターネットがプラットフォームとなった時代は、はじまったばかりだ」とO’Reilly氏は言う。まだどんなビジネスチャンスがあるのか、どんなロックインが出てくるのかは分からない。「Webサービスがオープンになるというのはどういうことか、データが本当にフリーになるというのはどういうことか、考えることはたくさんある」と課題提起した。

考え中ってことみたいです。APIだけじゃなく、データについても考えなくちゃいけないんですな。

Flickr Services

Serialized PHP Response Format

PHP has a built-in serialized data structure format, using the serialize() and unserialize() functions.

To return an API response in PHP serialized format, send a parameter ””format”” in the request with a value of ””php_serial””.

来てる!来てる!

p0t: PHPRPC

このフォーマットを汎用データ形式として広めようって剛の者はいないかな?

p0t: 鍵認証に目を反らすな

うーん・・・ パーミッションですが、$HOME/.sshだけでなく、 /や/homeや/home/USERNAMEが775だったりしてもダメなので、その確認をしたほうがいいかも 一度 StrictModes no でsshdを動かしてみるとか・・・

Posted by: Ryosuke | 2006年09月30日 03:58

Ryosukeさんの情報で鍵認証できない問題が解決しました。ありがとうございます!鍵認証に対する苦手意識が消えた!心理カウンセラーにも治せない俺の下らない悩みがどんどん解決していきます。

まとめときます。

手順:

ssh-keygen -t rsa
ssh komagata@komagata.no-ip.org "echo `cat ~/.ssh/id_rsa.pub`  >> ~/.ssh/authorized_keys"

チェックするところ:

  • RSAAuthentication yes、PubkeyAuthentication yes(普通はデフォルト)
  • /.sshが700、./.ssh/authorized_keysが600
  • /, /home, ~にgroup, other書き込み権限が無いこと(権限関連はStrictModes noで一応無視できる)

デフォルトですが、一応sshd_config載せときます。

# Package generated configuration file
# See the sshd(8) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
KeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

UsePAM yes

coLinuxが上手く行ったので今まで薄目開けて対応してた(出来たり出来なかったりしてたけどまあいいかと気にしないフリをしていた)鍵認証に正面から対応してみようと思います。

インスコしたcoLinuxからいくつかのサーバに公開鍵を登録してみた。やはり、行けるサーバと行けないサーバがある。

  • 行けるサーバ: komagata.sakura.ne.jp (FreeBSD 4.10、 OpenSSH_3.5p1)
  • いけないサーバ: komagata.no-ip.org (Debian Etch、OpenSSH_4.3p2)

鍵作成、登録手順:

ssh-keygen -t rsa
ssh komagata@komagata.sakura.ne.jp "echo `cat ~/.ssh/id_rsa.pub`  >> ~/.ssh/authorized_keys" 
ssh komagata@komagata.no-ip.org "echo `cat ~/.ssh/id_rsa.pub`  >> ~/.ssh/authorized_keys"

行ける時:

dev:~% ssh -vvv komagata@komagata.sakura.ne.jp
OpenSSH_4.3p2 Debian-3, OpenSSL 0.9.8c 05 Sep 2006
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to komagata.sakura.ne.jp [59.106.13.181] port 22.
debug1: Connection established.
debug1: identity file /home/komagata/.ssh/identity type -1
debug3: Not a RSA1 key file /home/komagata/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /home/komagata/.ssh/id_rsa type 1
debug1: identity file /home/komagata/.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.5p1 FreeBSD-20030924
debug1: match: OpenSSH_3.5p1 FreeBSD-20030924 pat OpenSSH_3.*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3p2 Debian-3
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_init: found hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_init: found hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 131/256
debug2: bits set: 515/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /home/komagata/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 3
debug3: check_host_in_hostfile: filename /home/komagata/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 4
debug1: Host 'komagata.sakura.ne.jp' is known and matches the DSA host key.
debug1: Found key in /home/komagata/.ssh/known_hosts:3
debug2: bits set: 537/1024
debug1: ssh_dss_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/komagata/.ssh/identity ((nil))
debug2: key: /home/komagata/.ssh/id_rsa (0x80953f0)
debug2: key: /home/komagata/.ssh/id_dsa ((nil))
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/komagata/.ssh/identity
debug3: no such identity: /home/komagata/.ssh/identity
debug1: Offering public key: /home/komagata/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug2: input_userauth_pk_ok: fp c6:91:7e:02:99:9b:93:51:48:de:7d:83:76:e9:4e:73
debug3: sign_and_send_pubkey
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Entering interactive session.
debug2: callback start
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 0
debug3: tty_make_modes: ospeed 38400
debug3: tty_make_modes: ispeed 38400
debug3: tty_make_modes: 1 3
debug3: tty_make_modes: 2 28
debug3: tty_make_modes: 3 127
debug3: tty_make_modes: 4 21
debug3: tty_make_modes: 5 4
debug3: tty_make_modes: 6 0
debug3: tty_make_modes: 7 0
debug3: tty_make_modes: 8 17
debug3: tty_make_modes: 9 19
debug3: tty_make_modes: 10 26
debug3: tty_make_modes: 12 18
debug3: tty_make_modes: 13 23
debug3: tty_make_modes: 14 22
debug3: tty_make_modes: 18 15
debug3: tty_make_modes: 30 0
debug3: tty_make_modes: 31 0
debug3: tty_make_modes: 32 0
debug3: tty_make_modes: 33 0
debug3: tty_make_modes: 34 0
debug3: tty_make_modes: 35 0
debug3: tty_make_modes: 36 1
debug3: tty_make_modes: 37 0
debug3: tty_make_modes: 38 1
debug3: tty_make_modes: 39 0
debug3: tty_make_modes: 40 0
debug3: tty_make_modes: 41 0
debug3: tty_make_modes: 50 1
debug3: tty_make_modes: 51 1
debug3: tty_make_modes: 52 0
debug3: tty_make_modes: 53 1
debug3: tty_make_modes: 54 1
debug3: tty_make_modes: 55 1
debug3: tty_make_modes: 56 0
debug3: tty_make_modes: 57 0
debug3: tty_make_modes: 58 0
debug3: tty_make_modes: 59 1
debug3: tty_make_modes: 60 1
debug3: tty_make_modes: 61 1
debug3: tty_make_modes: 62 0
debug3: tty_make_modes: 70 1
debug3: tty_make_modes: 71 0
debug3: tty_make_modes: 72 1
debug3: tty_make_modes: 73 0
debug3: tty_make_modes: 74 0
debug3: tty_make_modes: 75 0
debug3: tty_make_modes: 90 1
debug3: tty_make_modes: 91 1
debug3: tty_make_modes: 92 0
debug3: tty_make_modes: 93 0
debug1: Sending environment.
debug3: Ignored env USER
debug3: Ignored env LOGNAME
debug3: Ignored env HOME
debug3: Ignored env PATH
debug3: Ignored env MAIL
debug3: Ignored env SHELL
debug3: Ignored env SSH_CLIENT
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env SSH_TTY
debug3: Ignored env TERM
debug3: Ignored env SHLVL
debug3: Ignored env PWD
debug3: Ignored env OLDPWD
debug1: Sending env LANG = ja_JP.UTF-8
debug2: channel 0: request env confirm 0
debug3: Ignored env CVS_RSH
debug3: Ignored env CVSROOT
debug3: Ignored env SVN_EDITOR
debug3: Ignored env EDITOR
debug3: Ignored env LS_COLORS
debug3: Ignored env _
debug2: channel 0: request shell confirm 0
debug2: fd 3 setting TCP_NODELAY
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 131072
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California.  All rights reserved.

FreeBSD 4.10-RELEASE-p16 (SAKURA8) #0: Tue Aug  9 10:23:26 JST 2005

// Sakura internet rental server service

>

行けない時:

dev:~% ssh -vvv komagata@komagata.no-ip.org
OpenSSH_4.3p2 Debian-3, OpenSSL 0.9.8c 05 Sep 2006
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to komagata.no-ip.org [192.168.0.3] port 22.
debug1: Connection established.
debug1: identity file /home/komagata/.ssh/identity type -1
debug3: Not a RSA1 key file /home/komagata/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /home/komagata/.ssh/id_rsa type 1
debug1: identity file /home/komagata/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3p2 Debian-3
debug1: match: OpenSSH_4.3p2 Debian-3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3p2 Debian-3
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_init: found hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_init: found hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 128/256
debug2: bits set: 507/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /home/komagata/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug3: check_host_in_hostfile: filename /home/komagata/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 2
debug1: Host 'komagata.no-ip.org' is known and matches the RSA host key.
debug1: Found key in /home/komagata/.ssh/known_hosts:1
debug2: bits set: 536/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/komagata/.ssh/identity ((nil))
debug2: key: /home/komagata/.ssh/id_rsa (0x80953e8)
debug2: key: /home/komagata/.ssh/id_dsa ((nil))
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/komagata/.ssh/identity
debug3: no such identity: /home/komagata/.ssh/identity
debug1: Offering public key: /home/komagata/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/komagata/.ssh/id_dsa
debug3: no such identity: /home/komagata/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
komagata@komagata.no-ip.org's password:

“ファイルのパーミションのせいで認証できない”というのが典型的間違い所らしいけど、それじゃあない。

chmod 700 $HOME/.ssh
chmod 600 $HOME/.ssh/authorized_keys

ssh -vだと

「RSAで認証しようとしました。DSAで認証しようとしました。駄目なのでパスワード認証します。」

ってことしか分からなかったのでssh -vvvにしたんですが、意味が分かりません。

今日ここまでっ!!!

(追記)komagata.no-ip.orgのsshd_config:

# Package generated configuration file
# See the sshd(8) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
KeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

UsePAM yes