安装 ssh 的公开密匙到 iPhone 上

1). 在Mac的终端上产生密匙

ssh-keygen -t rsa
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): xxx
Enter same passphrase again: xxx
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:
e4:e8:b7:05:06:b3:f0:ff:af:13:fc:50:6a:5b:d1:b5 xxxx@localhost.localdomain
过程中会提问你通行证(passphrase),输入你常用的秘密。
 
2). 在 iPhone 上创建.ssh目录(iPhone的IP地址是10.0.2.2)
ssh root@10.0.2.2 'mkdir -p .ssh'
如果问道你iPhone root password,输入 alpine。
3). 拷贝刚才生成的公开密匙到 iPhone
cat ~/.ssh/id_rsa.pub | ssh root@10.0.2.2 'cat >> .ssh/authorized_keys'
如果问道你iPhone root password,输入 alpine。
4). 在 iPhone 上编辑 /etc/ssh/sshd_config 文件
#将

#StrictModes yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys

#替换为

StrictModes no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
5). 重新启动iPhone,OK!
 
 
by sschu
 
posted @ 2012-10-25 19:35  iPhone Dev  阅读(1090)  评论(0编辑  收藏  举报