2.25.2012

ssh into iPhone without password authentication

25 Feb 2012

To ssh into your iPhone without password authentication,

1.  add user on iPhone

# cat /etc/master.passwd > ~/master.passwd
# echo 'hoge:*:1001:1001::0:0:User:/var/hoge:/bin/sh' >> ~/master.passwd
# diff /etc/master.passwd ~/master.passwd
> hoge:*:1001:1001::0:0:User:/var/hoge:/bin/sh
# mv ~/master.passwd /etc/master.passwd
# passwd hoge
New password: (type password for hoge)
Retype new password: (retype password for hoge)
# cd /var; mkdir hoge; chown hoge hoge;

2 make identity.pub on Ubuntu

% ssh-keygen -t rsa -f ~/.ssh/identity -N ""
% scp ~/.ssh/identity.pub hoge@192.168.1.2
hoge@192.168.1.2's password: (type password for hoge)
% ssh hoge@192.168.1.2
hoge@192.168.1.2's password: (type password for hoge)

3 place identity.pub and modify sshd config on iPhone

# mkdir .ssh ; chmod 700 .ssh
# mv identity.pub .ssh/authorized_keys
# chmod 600 .ssh/authorized_keys
# su
Password: (type password for root)
# cat /etc/ssh/sshd_config > ~/sshd_config
# echo 'RSAAuthentication yes' >> ~/sshd_config
# echo 'PubkeyAuthentication yes' >> ~/sshd_config
# echo 'AuthorizedKeysFile .ssh/authorized_keys' >> ~/sshd_config
# diff /etc/ssh/sshd_config ~/sshd_config
> RSAAuthentication yes
> PubkeyAuthentication yes
> AuthorizedKeysFile .ssh/authorized_keys
# mv ~/sshd_config /etc/ssh/sshd_config
# reboot

4. now you can ssh with password authentication

Your-Ubuntu:~ hoge% ssh 192.168.1.2


0 件のコメント:

コメントを投稿