ちっぷす: MacOS X で ssh サーバーを起動する


用意すること

手順

以下をそのまま実行する。入力するのは太字の部分のみ。

[localhost:~] user% su -
Password: 表示されないが、入力する。
[localhost:~] root# ssh-keygen
Generating public/private rsa1 key pair.
Enter file in which to save the key (/var/root/.ssh/identity): /etc/ssh_host_key
Enter passphrase (empty for no passphrase): リターンキーのみ。
Enter same passphrase again: リターンキーのみ。
Your identification has been saved in /etc/ssh_host_key.
Your public key has been saved in /etc/ssh_host_key.pub.
The key fingerprint is:
ab:cd:ef:gh:ij:kl:mn:op:qr:st:uv:wx:yz:1a:2b:3c root@localhost
[localhost:~] root# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/var/root/.ssh/id_rsa): /etc/ssh_host_rsa_key
Enter passphrase (empty for no passphrase): リターンキーのみ。
Enter same passphrase again:
Your identification has been saved in /etc/ssh_host_rsa_key.
Your public key has been saved in /etc/ssh_host_rsa_key.pub.
The key fingerprint is:
ab:cd:ef:gh:ij:kl:mn:op:qr:st:uv:wx:yz:1a:2b:3c root@localhost
[localhost:~] root# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/var/root/.ssh/id_dsa): /etc/ssh_host_dsa_key
Enter passphrase (empty for no passphrase): リターンキーのみ。
Enter same passphrase again: リターンキーのみ。
Your identification has been saved in /etc/ssh_host_dsa_key.
Your public key has been saved in /etc/ssh_host_dsa_key.pub.
The key fingerprint is:
ab:cd:ef:gh:ij:kl:mn:op:qr:st:uv:wx:yz:1a:2b:3c root@localhost
[localhost:~] root# sshd &
[1] 654 この辺りの表示はいろいろ異なるが無視。
[localhost:~] root#

これで ssh サーバーが起動する。ほかの計算機から上記を実行した MacOS X の計算機に ssh でログインしたり scp でファイルをコピーしたりできる。 MacOS X をシャットダウンしたり再起動したりすると、SSH の設定は保存されているが、sshd は実行を終了するので、MacOS X の起動後にまた terminal を起動し、su して sshd を実行しなければならない。 具体的には terminal 上で、

[localhost:~] root# sshd &

とだけやる。