以下流程僅適用於自己擁有的越獄測試裝置,用於安全研究與學習。
首先在越獄裝置上安裝 OpenSSH 插件,然後查看裝置的 IP,這裡假設為 192.168.xxx.xxx。
接著在 Mac 的終端機透過 SSH 連線過去:
ssh root@設備IP位址
初次登入密碼是 alpine,這是公開的預設值,必須立即修改,否則同一網路上的任何人都能登入你的裝置。
修改密碼的指令是:
passwd
例如:
$ ssh root@192.168.xxx.xxx The authenticity of host '192.168.xxx.xxx (192.168.xxx.xxx)' can't be established. RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. Are you sure you want to continue connecting (yes/no)? Please type 'yes' or 'no': yes Warning: Permanently added '192.168.xxx.xxx' (RSA) to the list of known hosts. root@192.168.xxx.xxx's password: root#
修改密碼:
root# passwd Changing password for root. New password: Retype new password: root#
之後就能用 Mac 透過 SSH 連到 iOS 裝置上操作了。
SSH 是完整 shell 權限,操作失誤可能讓裝置開不了機,動手前請先確認資料已備份。
建議把 SSH 的連接埠從預設的 22 改掉,或直接關閉不必要的對外服務 —— 越獄裝置在公開網路上被掃到的概率不低,而 alpine 這個預設密碼幾乎人人皆知。
另外,若只是要傳檔案,用 scp 會比開互動式 shell 更方便,語法與 ssh 幾乎一致:
$ scp 本地檔案 root@192.168.xxx.xxx:/var/tmp