您的位置:首页 > 移动开发 > Android开发

android与pc的连接

2016-09-05 10:20 239 查看

本篇总结android通过ssh连接到电脑linux系统,以及电脑连接到android的shell。目的是 整理相关工具方便今后使用

应用场景:

连接pc
手机远程进入pc端工作

连接android
电脑wifi调试android


一、手机连接pc(前提pc端的linux已经安装ssh)

方法:

手机上下载安装[Server auditor](http://download.csdn.net/detail/kernel_/9621751)或者其他ssh客户端connectBot等


Server auditor界面比较友好,可以随意改变字体 颜色

1.填写pc的linux系统的user ip password等信息




2.连接结果




二、pc连接android,root手机

方法1:adb连接 网上很多开源的wifi调试工具源码(也可以直接下载app)

stf源码:https://github.com/openstf/stf
wifidebug源码:https://github.com/biglio23/WifiDebug
adbWireless源码: https://github.com/Skywriter-se/adbWireless


以上是使用adb通信 ,步骤:

1.app程序打开并且开启服务
2.在cmd命令中:  adb connect phone_ipaddress:portnumber


~~~~~~~~~~~~~~~

不使用上面的工具的情况:

cmd命令(配置tcp端口、连接)

adb kill-server                    #关闭adb服务
adb start-server                   #重启adb服务
adb tcpip 5555                     #端口
adb connect xxx.xxx.xxx.xxx:5555   #连接


参考 http://www.cnblogs.com/rainduck/p/3577181.html

不依靠工具,自己在终端配置service.adb.tcp.port(使用上面的工具就可以省略这些步骤)

TCP/IP配置:
/#setprop service.adb.tcp.port 5555  #设置端口
/#stop adbd                          #关闭adb
/#start adbd                         #重启adb

原来的usb配置:
/#setprop service.adb.tcp.port -1
/#stop adbd
/#start adbd


如下:android终端界面:



pc端

adb connect phone_ipaddress:portnumber(连接)
adb disconnect phone_ipaddress:portnumber(关闭)




方法2:在手机安装ssh服务器工具

手机ssh服务器软件有QuickSSHd或SSHDroid

pc上使用ssh客户端 如xshell等

步骤:

1.在手机上开启ssh服务,




2.得到root@192.168.1.113

3.pc上xshell建立连接 设置连接的用户名 密码 ip(SSHDroid设置的默认密码为admin)








4.结果:



现在得到shell。可以像linux系统一样输入命令控制手机(如同使用在手机安装的shell终端



输入 logcat命令:



命令:http://blog.csdn.net/shuaihj/article/details/8889465?reload
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息