Welcome to follow the official wechat account: FSA Full stack action 👋
Install OpenSSH
The premise of this article is that the device has been jailbroken!
Secure Shell (SSH) is a security protocol based on the application layer. It is used for encrypted login between computers and provides a Secure transmission environment for network services on insecure networks
Search for OpenSSH in Cydia and install it
account
Root: indicates the account with the highest permission. $HOME is /var/root
- Account:
root
- Password:
alpine
Changing the Login Password
- The login
root
account - Modify the
root
Password of the account, terminal input:passwd
Remote login
Method 1: Account password
Go to the “Settings” -> “Wi-Fi” page of your iOS device, find the network you are connected to, and check its IP address
If the IP address 192.168.10.104 is displayed in the preceding figure, enter:
SSH [email protected]Copy the code
Enter the password: alpine
Method 2: Password-free login
Compared with method 1, you do not need to ask for a password every time you connect to SSH
role | equipment | file |
---|---|---|
The client | Mac |
The public key~/.ssh/id_rsa.pub The private key ~/.ssh/id_rsa |
The server side | iPhone |
The authorization documents~/.ssh/authorized_keys |
1. Generate a secret key pair
ssh-keygen -t rsa
#By default, OpenSSH generates an RSA key. The -t parameter is the specified key type
#So the above command can omit the -t parameter: ssh-keygen
Copy the code
2. Upload the public key toiOS
equipment
Mode 1: Automatic (recommended)
Run the following command and enter the password
SSH - copy - id [email protected]Copy the code
Method 2: Manual
#This method overwrites the authorized_keys file directlySCP ~ /. SSH/id_rsa. Pub [email protected]: / var/root /. SSH/authorized_keysCopy the code
Since the authorized_keys file will be overwritten, it is best to upload id_Rsa. pub to the device and then append to authorized_keys
#Upload the public key to root's home directorySCP ~ /. SSH/id_rsa. Pub [email protected]: ~
#Logging In to an iOS DeviceSSH [email protected]
#Append content to authorized_keys
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
#Example Remove the uploaded public key
rm ~/id_rsa.pub
Copy the code
Now log in again and you won’t need to enter your password
3. Precautions
If the /var/root/. SSH directory does not exist on the iOS device, the following error message is displayed
scp: /var/root/.ssh/authorized_keys: No such file or directory
Copy the code
You need to log in to the device to create the directory
xunfengteki-iPad:~ root# cd /var/root/
xunfengteki-iPad:~ root# mkdir .ssh
Copy the code
If you still need to enter the password after the configuration, it may be that the file permissions are insufficient. You need to log in to the iOS device and run the following command to change the permissions on the files or directories
chmod 755 ~
#Set the.ssh directory permission
chmod 755 ~/.ssh
#Set the authorized_keys permission
chmod 644 ~/.ssh/authorized_keys
Copy the code
USB connected device
All of the above mentioned devices are connected through Wi-Fi, which has a big drawback, that is, when the network is not smooth, it will be slow. In order to ensure the transmission speed, you can solve this problem through USB connection
1, install,usbmuxd
brew install usbmuxd
Copy the code
2. Port mapping
Mapping local port 2222 to remote port 22
Iproxy 2222 22 [Device UDID]Copy the code
If multiple iOS devices are connected to the same Mac, add the DEVICE UDID to the end of the command. If there is only one iOS device, omit the UDID
3. Connect the device
SSH -p 2222 [email protected]Copy the code
Encapsulating common commands
Shuttle: simple terminal command shortcut menu, liverpoolfc.tv: fitztrev. Making. IO/Shuttle /
"IOS" : [{" iPhone USB connection ": [{" CMD" : "iproxy 2222 22", "inTerminal" : "new", "name" : "1. USB port mapping SSH"}, {" CMD ": "SSH root@localhost -p 2222", "inTerminal": "new", "name": "2. Connect to iPhone"}]}]Copy the code
Effect:
Now just click iOS -> USB to connect iPhone under 1.USB maps SSH port and 2. Connect iPhone, you can quickly use USB to connect our iOS devices, improve efficiency.
Chinese problem
By default, iOS terminals do not support Chinese input and display. When you enter Chinese, you will automatically delete all the current input content.
Solution: Create an.inputrc file in your home directory
touch ~/.inputrc
Copy the code
Contents of the document:
Set convert-meta off set output-meta on set meta-flag on set input-meta onCopy the code
If you want to edit file content on a terminal on an iOS device, search for Vi IMproved in Cydia and install it
After the installation is complete, enter:
vi ~/.inputrc
Copy the code
Press I to switch to the input mode, paste the content of the above file, press Esc to switch to the last mode, enter :wq, and press Enter to save and exit.
For example, I created a test. TXT, which shows \346\265\213\350\257\225.txt
Solution: search by Cydia Locale Profiles can be installed in utf-8 and source BigBoss:http://apt.thebigboss.org/repofiles/cydia/ (software)
Exit the iOS terminal at this time, but also re-enter the solution!
Click the file system content at the bottom of the details page
As you can see, the plugin installed the Chinese language package in /usr/share/locale and created localeutf8.sh in /etc/profile.d/, setting the current language to en_us.utf-8
xunfengtekiiPhone:~ root# cat /etc/profile.d/localeutf8.sh
export LANG="en_US.UTF-8"
Copy the code