iOS逆向之三 authorized_keys ssh登入越獄手機免驗證設定

aron1992發表於2019-04-04

iOS逆向之三-authorized_keys ssh登入越獄手機免驗證設定

預設情況下使用ssh登入到iPhone每次都是需要輸入密碼的,比較繁瑣,可以配置ios的authorized_keys和電腦端的一致來簡化這個步驟

電腦配置

刪除 ~/.ssh/known_hosts檔案的配置

known_hosts 的檔案如下

➜  .ssh cat known_hosts  
192.168.8.220 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7ZyuWzvOD7ZvO4cvz+OI9npOmCLkqIPIEMUg+A0/TL3MxB+KGEC7XaEI4tZb/617w9sIJbH0LeXlwAb7be0lrLDntXnH9mQV0DcI94mfOmMKCZtzBcPiHqYVFiEXi4Gtdn2Ki8wH8s5EvIB+Xtad2ZCoR9KpDFxINw9SkMvxAK5zO6RkoQbe8EHKK2986d+QrnT39HfqymP744RhCABuSkGTyeIFBYJlqjUT+HocLfIrF4MBdQul4JJa7rcm7F3NDp+DLryAh6/yJRsXSlM2RcdkbvhD2Cvvd+YJCcD0LPht1Nibf91htvd2glUjoU4DpIUwd7RI8OvVH+QETXjO9
192.168.8.215 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7ZyuWzvOD7ZvO4cvz+OI9npOmCLkqIPIEMUg+A0/TL3MxB+KGEC7XaEI4tZb/617w9sIJbH0LeXlwAb7be0lrLDntXnH9mQV0DcI94mfOmMKCZtzBcPiHqYVFiEXi4Gtdn2Ki8wH8s5EvIB+Xtad2ZCoR9KpDFxINw9SkMvxAK5zO6RkoQbe8EHKK2986d+QrnT39HfqymP744RhCABuSkGTyeIFBYJlqjUT+HocLfIrF4MBdQul4JJa7rcm7F3NDp+DLryAh6/yJRsXSlM2RcdkbvhD2Cvvd+YJCcD0LPht1Nibf91htvd2glUjoU4DpIUwd7RI8OvVH+QETXjO9
複製程式碼

比如說你的iPhone手機IP是192.168.8.215,那麼就把這一項的配置刪除,刪除之後的配置如下即可。

➜  .ssh cat known_hosts  
192.168.8.220 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7ZyuWzvOD7ZvO4cvz+OI9npOmCLkqIPIEMUg+A0/TL3MxB+KGEC7XaEI4tZb/617w9sIJbH0LeXlwAb7be0lrLDntXnH9mQV0DcI94mfOmMKCZtzBcPiHqYVFiEXi4Gtdn2Ki8wH8s5EvIB+Xtad2ZCoR9KpDFxINw9SkMvxAK5zO6RkoQbe8EHKK2986d+QrnT39HfqymP744RhCABuSkGTyeIFBYJlqjUT+HocLfIrF4MBdQul4JJa7rcm7F3NDp+DLryAh6/yJRsXSlM2RcdkbvhD2Cvvd+YJCcD0LPht1Nibf91htvd2glUjoU4DpIUwd7RI8OvVH+QETXjO9
複製程式碼

生成authorized_keys

➜  ~ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/aron/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/aron/.ssh/id_rsa.
Your public key has been saved in /Users/aron/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:EH+sVXPn72+iXqGMLMEXMtuW9/PNlZcvOixBXezJWBo aron@aron-MacBook-Pro.local
The key's randomart image is:
+---[RSA 2048]----+
|      .     o.. .|
|       o . .Eo+o |
|      . + =. O ..|
|       o O.o+ + .|
|        S.= . . .|
|         =.+ o oo|
|        . ooo +o+|
|         .. o.o+B|
|           o++ +*|
+----[SHA256]-----+
複製程式碼

拷貝authorized_keys檔案

➜  ~ cd ~/.ssh
➜  .ssh cp id_rsa.pub ~/authorized_keys
複製程式碼

ios手機配置

iPhone:/User root# ssh-keygen 
Generating public/private rsa key pair.

Enter file in which to save the key (/var/root/.ssh/id_rsa): Created directory '/var/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /var/root/.ssh/id_rsa.
Your public key has been saved in /var/root/.ssh/id_rsa.pub.
The key fingerprint is:
de:f8:4c:d6:32:9b:6d:68:c9:c0:f5:17:29:3c:94:1e root@iPhone
The key's randomart image is:
+---[RSA 2048]----+
|             .   |
|            E    |
|           + . . |
|          . = o  |
|       .S. . o . |
|       .oo .. .  |
|        oo*o..   |
|         ==*.    |
|         .=..    |
+-----------------+
複製程式碼

退出ssh登入,拷貝電腦的authorized_keys檔案到iPhone中

iPhone:/User root# logout
Connection to 192.168.1.86 closed.
➜  theos git:(master) ✗ scp ~/authorized_keys root@192.168.1.86:/var/root/.ssh
The authenticity of host '192.168.1.86 (192.168.1.86)' can't be established.
RSA key fingerprint is SHA256:1X8esSMK4inAEDTDKkfVoI+YeFxcatt9HVZONu9UG7M.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.86' (RSA) to the list of known hosts.
root@192.168.1.86's password: 
authorized_keys                                                                               100%  409     3.6KB/s   00:00    
複製程式碼

重新登入,這時候就不需要密碼了,包括在tweak的時候也是不用繁瑣的密碼輸入步驟了。

➜  theos git:(master) ✗ ssh root@192.168.1.86
複製程式碼

相關文章