文章目录
安装Android Studio,配置SDK路径,创建虚拟设备,连接USB调试,编写并运行第一个Android应用。
安装OpenSSH服务器
1、打开终端,输入以下命令安装OpenSSH服务器:
sudo aptget update sudo aptget install opensshserver
2、安装完成后,启动OpenSSH服务器:
sudo systemctl start ssh
3、设置开机自启动:
sudo systemctl enable ssh
配置Android环境
1、下载并安装Termux应用:在Google Play商店中搜索“Termux”,然后安装。
2、打开Termux,输入以下命令更新软件包列表:
pkg update
3、安装SSH客户端:
pkg install openssh
4、配置Android设备的网络设置,使其能够访问到OpenSSH服务器,确保设备和服务器在同一局域网内,并且设备已连接到WiFi或移动数据网络。
连接Android设备到OpenSSH服务器
1、在Android设备上打开Termux,输入以下命令连接到OpenSSH服务器(将your_server_ip
替换为实际的服务器IP地址):
ssh your_server_username@your_server_ip p 2222 pw your_server_password l your_local_port D your_local_port N R your_remote_port:localhost:your_remote_port f v o ServerAliveInterval=60 o ServerAliveCountMax=5 o ConnectTimeout=10 o StrictHostKeyChecking=no o UserKnownHostsFile=/dev/null o LogLevel=ERROR o Compression=no o TCPKeepAlive=yes o IdentitiesOnly=yes o ControlMaster=auto o ControlPersist=600 o LocalCommand="your_local_command" o ServerAliveInterval=60 o ServerAliveCountMax=5 o ConnectTimeout=10 o StrictHostKeyChecking=no o UserKnownHostsFile=/dev/null o LogLevel=ERROR o Compression=no o TCPKeepAlive=yes o IdentitiesOnly=yes o ControlMaster=auto o ControlPersist=600 o LocalCommand="your_local_command"
2、如果连接成功,你将看到类似于以下的输出信息:
debug1: Connection to port 2222 forwarding to address localhost port your_local_port requested. debug1: channel 0: new [clientsession] debug1: Requesting nomoresessions@openssh.com debug1: Entering interactive session. Last login: Tue Jul 14 17:38:39 2020 from your_server_ip port 59998 ssh2<br>Your local command is running on the remote server. You can now exit the terminal and continue using your Android device as normal. Your local command will continue to run until you stop it or disconnect from the server. To stop the local command, simply close the terminal window or type "exit" in the terminal. To disconnect from the server, type "exit" in the terminal followed by "quit".