わいえむねっと

Contents
Categories
Calendar
2010/07
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
Monthly Archives
~2000/01
Recent Entries
RSS1.0
Templates
Information
Processed: 0.086 sec
Chashed: -
2010/07/11 Sun
正露丸投与。 Windows CE 版の PortForwarder は SSH2 非対応のため、sigmarionIII で使用する SSH クライアントの乗り換えを検討してみる。
SDカードスロットも復活したことだし。



PocketPutty


  • PocketPuTTY_PPC2k2_release_2007-02-28.zip
  • ダミーDll(H/PC2000以降用) 2006/07/23

が動作。ただ、単純に起動した場合は


Unable to open connection to

となる。設定画面が開くわけじゃないのか。

> putty username@hostname

のように引数で接続先を指定してやると普通に繋がる。


かなり文字が小さい。



OpenSSH


  • ssh-wince-arm-hpc-wce211.tar.gz
  • celib-3.13-dll-bin-all-platforms.tar.gz (wince-arm-hpc-wce211-release)
  • ダミーDll(H/PC2000以降用) 2006/07/23

  • ssh-wince-arm-hpc-wce300.tar.gz
  • celib-3.13-dll-bin-all-platforms.tar.gz (wince-arm-hpc-wce300-release)
  • ダミーDll(H/PC2000以降用) 2006/07/23

どちらの組み合わせも動作。


ただし、設定が色々と必要。以下、トライアンドエラー記録。

Couldn't get password entry for current user (0): No such file or directory

  • エラー出力箇所
openssh-2.9p2\entropy.c
    pw = getpwuid(original_uid);
    if (pw == NULL)
        fatal("Couldn't get password entry for current user (%i): %s",
            original_uid, strerror(errno));

  • getpwuid 定義
celib-palm-3.0\inc\cecrt_defs.h
  #define getpwuid xcegetpwuid

celib-palm-3.0\pwd.c
/* get passwd entry by userid */
struct passwd *
xcegetpwuid(uid_t uid)
{
  struct passwd *pw = NULL;

  xcesetpwent();
  while((pw = xcegetpwent()) != NULL)
    {
      if(uid == pw->pw_uid)
        break;
    }
  xceendpwent();
  return pw;
}

  • xcegetpwent でファイルの走査
celib-palm-3.0\pwd.c
struct passwd *
xcegetpwent(void)
{

  if(fpw == NULL)
    return NULL;

  if(feof(fpw))
    return NULL;

  if(fgets(pwbuf, sizeof(pwbuf), fpw) == NULL)
    return NULL;

celib-palm-3.0\pwd.c
  XCEGetEnvironmentVariableFromRegA("UNIXROOTDIR", path, sizeof(path));

  if(strcmp(path, "\\") == 0 || strcmp(path, "/") == 0)
    strcat(path, "etc\\passwd");
  else
    strcat(path, "\\etc\\passwd");

  fpw = fopen(path, "rt");

  • XCEGetEnvironmentVariableFromRegA 定義
celib-palm-3.0\ceutil.c
int
XCEGetEnvironmentVariableFromRegA(const char *name, char *buf, int len)
{

  if((res = XCERegOpenKeyExA(HKEY_LOCAL_MACHINE, "Environment", 0,
                             KEY_READ, &hKey)) != 0)
    {
      return 0;
    }

HKEY_LOCAL_MACHINE\Environment\UNIXROOTDIR からパスを取得しているので、レジストリに以下のキーを追加。
※"SD メモリ カード" は "SD Card" に変更済み。

[HKEY_LOCAL_MACHINE\Environment]
"UNIXROOTDIR"="\\SD Card\\UnixRoot"

\SD Card\UnixRoot\etc ディレクトリを作成し、空の passwd ファイルを置いてみる。

Couldn't get password entry for current user (0): No error

"No such file or directory" から "No error" に変化。
ここで、"current user" について追いかけてみる。

openssh-2.9p2\entropy.c
    pw = getpwuid(original_uid);

openssh-2.9p2\entropy.c
void
init_rng(void)
{
    int original_euid;

    check_openssl_version();

    original_uid = getuid();
    original_euid = geteuid();

celib-palm-3.0\inc\cecrt_defs.h
#define getuid xcegetuid

celib-palm-3.0\uid.c
int
xcegetuid()
{
  return 0;
}

0固定でした。
これを踏まえて passwd ファイルを作成。(というか、適当なLinux環境からコピーして加工)

\SD Card\UnixRoot\etc\passwd
root:x:0:0:root:/root:/bin/bash

Cannot open \SD Card\UnixRoot/etc/services



services がないと怒られたので作成。

\SD Card\UnixRoot\etc\services
ssh 22/tcp

これで、とりあえず繋がるように。


その他の設定

.ssh ディレクトリの作成

Could not create directory '/root/_ssh'.

passwd ファイルで指定したホームの下にディレクトリを掘ろうとしているようなので、\SD Card\UnixRoot\root ディレクトリを作成した上で passwd ファイルを更新。

\SD Card\UnixRoot\etc\passwd
root:x:0:0:root:/SD Card/UnixRoot/root:/bin/bash

すると、

Failed to add the host to the list of known hosts (/SD Card/UnixRoot/root/.ssh/known_hosts2).

掘っていたのは _ssh なのに、.ssh 下にファイルを保存しようとしている?(単に別の処理かも)
あらかじめ .ssh ディレクトリを掘っておけば、そこに known_hosts2 が保存される。

ログ出力先の変更

デフォルトでは "マイ コンピュータ" 直下に

  • ssh-stdin.txt
  • ssh-stdout.txt
  • ssh-stderr.txt

が出力されるので、これをSDカードに移動する。
\SD Card\UnixRoot\var\log ディレクトリを作成した上でレジストリに

[HKEY_LOCAL_MACHINE\Environment]
"CELIBSTDLOGDIR"="\\SD Card\\UnixRoot\\var\\log"

を追加。

TERM 指定

デフォルトでは

No value for $TERM and no -T specified

と警告がでるので、レジストリに

[HKEY_LOCAL_MACHINE\Environment]
"TERM"="vt100"

を追加。
というか、termcap ファイルの作成と HKEY_LOCAL_MACHINE\Environment\TERMCAP の指定を合わせて行うべきなんだろうと思うけど。とりあえず。


起動引数

ログイン関連について、いくつか確認。

> ssh
> ssh username@hostname
> ssh username@hostname -i "/SD Card/id_rsa"
> ssh username@hostname -1 -i "/SD Card/identity"

  • username@hostname を省略しても問題ない(コンソールで入力を求められる)
  • SSH1/SSH2 ともに接続可
  • id_rsa を .ssh ディレクトリに置いておけば勝手に読みにいく



リンク


PocketPuTTY Homepage
http://www.pocket​putty.net/

General Paranoyaxc Home
http://www.rainer​-keuchel.de​/


The HKLMEnvironment Key
http://www.rainer​-keuchel.de​/wince/registry.h​tml
My celib.dll uses the registry to store environment variables. They are stored in HKEY_LOCAL_MACHINE\Environment. This key does not exist by default.


WindowsCE FreeWare
http://www.geocit​ies.jp/hou_ming_2​/
ダミーDll(H/PC2000以降用) 2006/07/23

Generall Paranoyaxc 関連の和訳

CELib - Walrus, Digit
http://digit.que.​ne.jp/work/wiki.cgi?CELib

CERegistry - Walrus, Digit
http://digit.que.​ne.jp/work/wiki.cgi?CERegistry​

OpenSSH 導入例

Secure Telnet for Windows CE 2.00 Installation for OpenSSH
http://www.eskimo​.com/~webguy/service/openssh.ht​ml