Ubuntu-Touch-03: Use SSH to connect to the phone

open ssh

Purpose: Open the ssh connection to connect the mobile phone through the computer using the network, and it is more convenient and quick to type commands on the computer.
method:

  1. Open "Terminal"
    insert image description here
  2. Enter the password you set
    insert image description here
  3. Enter sudo su rootafter entering, then enter the password, it will not be displayed when entering the password, and this interface will be displayed after entering the password and pressing Enter
    insert image description here
  4. Enter cd ~to enter the root directory (because this is under the root user, so the entry is the root directory), and it will display like this after typing and pressing Enter
    insert image description here
  5. Enter mount -o remount rw /(be careful not to make mistakes, that is a lowercase letter o, not the number 0, and there is a space between rw and /)
    insert image description here
  6. Input ssh-keygen, everything that appears :is for you to enter parameters, we don’t need to enter parameters, just press Enter, until the familiarroot@ubuntu-phablet:~#
    insert image description here
  7. Then enter the command android-gadget-service enable ssh, and this interface appears, which means that the opening is successful.
    insert image description here
  8. Input cp /root/.ssh/id_rsa /home/phablet/Documents/ssh-rsa(be careful not to make a mistake, the uppercase of the Documents inside should not be lowercase)
    insert image description here
  9. Enter chmod 777 /home/phablet/Documents/ssh-rsa, change the file permission to 777, otherwise it will not work later
    insert image description here
  10. Connect the data cable to the computer, double-click to open "This Computer" on the desktop, double-click to open the displayedRedmi 4X
    insert image description here
  11. Double-click to enter Redmi 4X(the one on the left is the TF card I inserted, don't care)
    insert image description here
  12. Double click to enter Documentsthe folder
    insert image description here
  13. Copy ssh-rsathe file to your computer and save it
    insert image description here

Install Xshell and Xftp software

To connect to the mobile phone through ssh, you need to use the ssh command to operate, but the traditional ssh connection and use are not very convenient, so we use this software to connect and set.

  1. Open the link: https://www.xshell.com/zh/free-for-home-school/
  2. Click "Both", and enter your name and your email address (any name, just enter a), click download
    insert image description here
  3. Open the mailbox, find the email he sent to you, click it, there is a download link, click the link to start the download (2 emails, one Xshell, one Xftp, all must be downloaded)
    insert image description here
  4. Open the downloaded installation package to install (both must be installed, it is recommended to install Xshell first)
  5. Open the software after the installation is complete (after the Xftp installation is complete, just close it)

Use Xshell to connect to the phone

  1. To connect to a mobile phone, you must first know the IP address of the mobile phone. The method is very simple, open the router management page, enter the password, and find the IP address of the mobile phone
    insert image description here
  2. Set the binding between IP and MAC to prevent the IP from changing when the phone connects to the router next time
    insert image description here
  3. Open the Xshell software, and the "Session" interface will pop up automatically
  4. Click "New" in the upper left corner
    insert image description here
  5. The name is random, and the IP address is filled in the host
    insert image description here
  6. Click "User Authentication" on the left, enter root as the user name, delete the method Password, check it Public Key, and select Public Keyit to turn blue
    insert image description here
  7. Click "Settings" on the right, then click "Browse"
    insert image description here
  8. Click "Import"
    insert image description here
  9. Select the SSH public key saved to the computer, and click "Open"
    insert image description here
  10. Select the imported public key and click OK
    insert image description here
  11. Click OK, then click OK
    insert image description here
  12. You can see it in the "Session" interface, double-click to start the connection
    insert image description here
  13. The SSH security window will pop up for the first time, click "Accept and Save"
    insert image description here
  14. If this prompt appears when Xshell connects: the selected user key is not registered on the remote host, just enter this command:cp .ssh/id_rsa.pub .ssh/authorized_keys

Previous: Ubuntu-Touch-02: Start flashing
Next: Ubuntu-Touch-04: Use Xshell and Xftp to configure the phone

Guess you like

Origin blog.csdn.net/weixin_43381677/article/details/122710883