是否有任何命令行SSH客户端可用于rooted Android手机? -- ssh 领域 和 command-line 领域 android 相关 的问题

Are there any command line SSH clients available for rooted Android phones?


简体版||繁體版
24
vote

问题

中文

我当然有connectbot,但我正在寻找我可以脚本的东西。

编辑:要澄清这里,我对来自终端的脚本不感兴趣。我要做的是以自动/计划方式运行SSH命令。 tasker和locale执行是Cron的等同器,我只需要的是'ssh'命令从 脚本运行

英文原文

I of course have ConnectBot, but I'm looking for something I can script.

Edit: To clarify here, I'm not interested in running scripts from a terminal. What I want to do is run an SSH command in an automated/scheduled manner. Tasker and Locale Execute are the equivalent of cron, all I need is the 'ssh' command to run from the script.

     
 
 

回答列表

12
 
vote
vote
最佳答案
 

您可以从谷歌安装终端仿真器或者,存在更好的终端仿真器pro 。我尝试了在非生根手机上的终端仿真器,似乎工作正常。

更好的终端仿真器pro包括 dropbear ssh client ,可以从中启动命令行或通过发射器。 来自作者的更多信息

 

You can install the Terminal Emulator from google. Alternatively there is the Better Terminal Emulator Pro. I tried the Terminal Emulator on a non-rooted phone and it seemed to work fine.

Better Terminal Emulator Pro includes the dropbear ssh client, which can be launched from the command line or via a launcher. More info from the authors.

 
 
         
         
17
 
vote

因为我的原始问题是关于一个ssh二进制文件,并且有一个答案,我会接受这个答案。但是,还有另一种方法可以做我想做的事情,有点可能对某人有趣。

tasker + connectbot可用于执行任意远程(或本地,我猜,但是当时的区域设置更好)命令。

步骤1:在ConnectBot中设置连接。

  • 您可以在ConnectBot中具有重复连接,只要它们具有不同的别名即可。您必须先重命名一个(远离用户@主机)以创建第二个。长按并选择"编辑主机" 以执行这些更改。
  • 您可能希望在没有密码的情况下设置一个SSH密钥,以便您可以使用此操作以实现自动化。
  • 一旦连接实际工作,您可以使用"登录后自动化" 添加要运行的远程命令。确保最后有一个空白行,以便在上次命令后发送输入。使用Enter或;分开命令。我建议使用像"Echo Hello" 这样的东西作为测试,直到您确定事情正在工作,并且如果您不想留下连接,则"退出" 。
  • 在隔离中测试这一点。

步骤2:创建一个Tasker任务以调用ConnectBot。

  • 在Tasker中创建一个新任务。
  • 添加一个动作。来自MISC,选择"动作意图"
  • 字段是:
    • action:android.intent.action.view
    • cat
    • cat:默认
    • 数据:SSH URL,以"SSH://用户@ host /#alias" 的形式(没有引号)。这里的别名,用户和主机匹配在步骤1.
    • 中设置的别名
    • 目标:活动
    • 单击测试。 ConnectBot应该打开,您的命令应在远程主机上执行。

步骤3:在Tasker中使用此任务,但您通常会使用此任务。

 

Since my original question was about an ssh binary, and there is an answer for that, I'll accept that answer. However, there is another way to do what I wanted to do, kinda, that might be interesting to someone some day.

Tasker + ConnectBot can be used to execute arbitrary remote (or local, I guess, but Locale Execute is better for that) commands on a schedule.

Step 1: Set up your connection in ConnectBot.

  • You can have duplicate connections in ConnectBot as long as they have different aliases. You have to rename one first (away from user@host) in order to create the second. Long Press and select "Edit Host" to perform these changes.
  • You probably want to set up an ssh key without a password so that you can use this for automation.
  • Once the connection actually works, you can use "Post-login automation" to add the remote commands you would like to run. Make sure there is a blank line at the end so that enter is sent after your last command. Use enter or ; to separate commands. I suggest using something like "echo hello" as a test until you are sure things are working, and "exit" at the end if you don't want to leave the connection open.
  • Test this in isolation.

Step 2: Create a Tasker Task to call connectbot.

  • Create a new Task in Tasker.
  • Add an Action. From Misc, select "Action Intent"
  • The fields are:
    • Action: android.intent.action.VIEW
    • Cat: Default
    • Data: ssh url, in the form of "ssh://user@host/#alias" (without the quotes). The alias, user and host here must match the alias you set up in Step 1.
    • Target: Activity
    • Click Test. Connectbot should open and your commands should execute on the remote host.

Step 3: Use this Task in Tasker however you would normally.

 
 
     
     
5
 
vote

我知道这是一个旧的线程,但想要+1关于btep

的评论

我也使用btep的ssh二进制二进制二进制,但我只是把它从它的路径称为路径而不是链接它 /data/data/com.magicandroidapps.bettertermpro/bin/ssh root@192.168.1.1

或生成一对密钥并使用公钥身份验证 /data/data/com.magicandroidapps.bettertermpro/bin/ssh -i /data/data/com.magicandroidapps.bettertermpro/home/.ssh/d_rsa -l root 192.168.1.1

我在各种脚本中使用来自sl4a r4的上面的命令,它可以正常工作:)

在我可以做到这一点之前,我需要chmod a + x / data/data/com.magicandroidapps.bettertermpro/home/.ssh

一旦完成,您将使用titaniumbackup备份/恢复btep权限,如果您刷新新ROM,则只需恢复应用程序,您的脚本将再次工作

 

I know it's an old thread but wanted to +1 the comment about BTEP

I'm also using BTEP's ssh binary though I just call it from it's path instead of linking it /data/data/com.magicandroidapps.bettertermpro/bin/ssh root@192.168.1.1

or generate a pair of keys and use public key authentication /data/data/com.magicandroidapps.bettertermpro/bin/ssh -i /data/data/com.magicandroidapps.bettertermpro/home/.ssh/id_rsa -l root 192.168.1.1

I use the above command from SL4A r4 in various scripts and it works fine :)

before I could do this I needed to chmod a+x /data/data/com.magicandroidapps.bettertermpro/home/.ssh

once this is done and you backup/restore BTEP with TitaniumBackup the permissions are kept this means if you flash a new rom you can just restore the apps and all your scripts will work again

 
 
5
 
vote

我已成功使用 botbreg basil实验< / a>运行Android 4.4。 BotBroge Basil实验基于APT-GET,因此在安装APK和引导后,我刚刚在根shell中执行了 abcdefghijklmnapt-get install dropbear 来安装ssh客户端(和服务器)。

 

I have successfully used BotBrew Basil Experimental when running Android 4.4. BotBrew Basil Experimental is based on apt-get so after installing APK and bootstraping I just did apt-get install dropbear in a root shell to install SSH client (and server).

 
 
3
 
vote

安装终端仿真器和Quickssh。 Quickssh还包括Dropbear。不花掉你的钱,它不应该因为这是经过多大的简单,它基于Dropbear。

https://play.google.com/商店/应用程序/详细信息?id = berserker.android.apps.sshdroid

find -name ssh 用户@ host

问题解决了

 

Install terminal emulator and quickssh. Quickssh also includes dropbear. Does not cost you money, which it should not because this is surpassingly simple and it's based on dropbear.

https://play.google.com/store/apps/details?id=berserker.android.apps.sshdroid

find -name ssh user@host

Problem solved

 
 
 
 
2
 
vote

终端仿真器绝对支持脚本*。不要相信Nay-Sayers。如果您尚未熟悉它,您需要学习Bash Shell Scripting。编写脚本并将其保存在SD卡上。从术语开始使用"sh filename" 。

如果你澄清你想要的"脚本" 与ssh有关,我很可能会给你一个更好的建议。

*(它实际上是支持Bash脚本的Android操作系统,终端仿真器只是授予您访问Android shell的授予,因此脚本本质是可能的)

 

Terminal Emulator absolutely supports scripts*. Don't believe the nay-sayers. You will need to learn BASH shell scripting, if you're not already familiar with it. Write a script and save it on your SD card. Run it with "sh filename" from Term.

If you clarify what it is you want to "script" having to do with SSH, I can likely give you a better recommendation.

*(It's actually the Android OS that supports BASH scripts, Terminal Emulator just grants you access to the Android shell, therefore scripting is inherently possible)

 
 
   
   
2
 
vote

从脚本调用ssh,您需要做的就是设置SSH键。网络上有一百万次TO-TOS,但是在Cyanogen Wiki上有一个页面,可能更适合Android用户。设置键后,您的常规SSH命令看起来像这样:ssh -i / path / to / key user @ ip

可以将其放在脚本中,运行它,您将登录到远程计算机。

但这是我认为你想要做的事情。仅在远程计算机上执行命令,只需在单引号中添加它:ssh -i / path / to / key user @ ip'命令'

在未记录远程计算机上执行命令,无需记录。您可以使用选项,管道,重定向等运行命令,但有时会更好地保持它们。除了延迟之外,它看起来与在本地执行命令并可以使用相同。

locale执行可以挑剔它将运行的命令。如果它不起作用,请尝试将其放入脚本并使用语言环境执行运行脚本。

此外,我在手机上有SSH二进制文件的问题,发现从/系统/ Xbin移动它并在/系统/ xbin / ssh中创建链接到更好的终端仿真器SSH二进制更可靠。 BTEP二进制文件位于/data/data/com.magicandroidapps.bettertermpro/bin/ssh
 

To call ssh from a script, all you need to do is set up ssh keys. There are a million how-tos on the web, but there's a page on the Cyanogen wiki that might be more suited to Android users. Once you set up keys, your general ssh command would look something like this: ssh -i /PATH/TO/KEY USER@IP

You can put that in a script, run it, and you will be logged in to the remote machine.

But here's what I think you're wanting to do. To only execute a command on a remote computer, just add it in single quotes: ssh -i /PATH/TO/KEY USER@IP 'command'

That executes the command on the remote machine without logging you in. You can run commands with options, pipes, redirects etc, but it's sometimes better to keep them simple. Except for the delay, it looks the same as executing the command(s) locally and can be used the same.

Locale Execute can be picky about what commands it will run. If it doesn't work, try putting it in a script and using Locale Execute to run the script.

Also, I have had problems with the ssh binary that is on the phone and found that moving it from /system/xbin and creating a link at /system/xbin/ssh to the Better Terminal Emulator ssh binary is more reliable. The BTEP binary is in /data/data/com.magicandroidapps.bettertermpro/bin/ssh

 
 
2
 
vote

botbrew 是Android的包管理器 okpg 对于BSD或更新,例如 APT for debian。挺棒的。它没有一个ssh客户端作为包,但如果您用于构建您自己的包,则它看起来并不太难。它可能是一个有用的工具链,当您想要构建其他C / C ++ / ETC二进制文件和库时。

所以但尽管这不是直接答案,但有些人可以了解这一点。
 

Botbrew is a package manager for Android, in the likes of okpg for BSD or more recently, like APT for Debian. Pretty nice. It doesn't have an ssh client as a package, but it doesn't look too hard to put in if you're used to building your own packages. And it could be useful as a toolchain for when you want to build other C/C++/etc binaries and libraries.

So albeit this isn't a direct answer, it may be useful for some people to know about.

 
 
     
     
2
 
vote
现在,现在有一个名为termux的终端,您可以易于安装openssh。在 Google Play Store , f-droid ,和 github 。
 

Now there is a terminal called Termux that you can apt install openssh in. Available on Google Play Store, F-Droid, and Github.

 
 
 
 
-1
 
vote

ANDFTP可以通过您配置的任何端口连接,因此我确定它可以通过SSH连接。但我不确定脚本使用它是多么容易。我一直在我的托管服务器使用应用程序,它很棒。

不确定是否可以使用终端仿真器SSH,但您也可以尝试。我经常使用那个应用程序来做事情,我懒得与adb做。

 

AndFTP can connect over any port you configure so I'm sure it could connect over SSH. But I'm not sure how easy it is to script usage of it. I use the app myself all the time for my hosting server and it works great.

Not sure if you can SSH with Terminal Emulator, but you could try it too. I use that app frequently for doing things I'm too lazy to do with ADB.

 
 
   
   
-1
 
vote

使用ssh插件for tasker?那么不需要root或ssh二进制。

 

Use an ssh plugin for Tasker? Don't need root or ssh binary then.

 
 
   
   
-3
 
vote

如果简单的ssh客户端对您有趣,我在android-ndk仿生库drobpear-ssh-client下制作。 ftp://ftp.simtreas.ru/pub/my/dropbear /dropbear-ssh-only.tgz 顺序和 ftp://ftp.simtreas.ru/pub/my/dropbear/ssh二进制

 

If the simple ssh client is interesting to you, I made under Android-NDK Bionic library drobpear-ssh-client-only. ftp://ftp.simtreas.ru/pub/my/dropbear/dropbear-ssh-only.tgz sourse and ftp://ftp.simtreas.ru/pub/my/dropbear/ssh binary

 
 
 
 

相关问题

0  如何修复“mount:'remount' - >'/ system':没有这样的文件或目录”?  ( How to fix mount remount system no such file or directory ) 
angler:/ # mount -o rw, remount /system mount: 'remount'->'/system': No such file or directory 1|angler:/ # 当我在手机中尝试在Kali Linux中: root@kali:~# mount -o ...

1  是否可以在Android上安装“IPRUTE2”?  ( Is it possible to install iproute2 on android ) 
我试图在googleSource的页面中使用 git clone ,但它没有多大。我想从包中使用 ss 命令,但我不知道如何安装它。我的手机是手臂32位。 ...

24  是否有任何命令行SSH客户端可用于rooted Android手机?  ( Are there any command line ssh clients available for rooted android phones ) 
我当然有connectbot,但我正在寻找我可以脚本的东西。 编辑:要澄清这里,我对来自终端的脚本不感兴趣。我要做的是以自动/计划方式运行SSH命令。 tasker和locale执行是Cron的等同器,我只需要的是'ssh'命令从 脚本运行 。 ...

24  是否可以从命令行激活“USB系列”Android设置?  ( Is it possible to activate the usb tethering android setting from the command ) 
我想在Bash脚本中激活"USB系列" ,因此有可能使用 adb shell 来运行命令行以更改一些Android设置? edit1 : 以下命令打开所需的设置,但不单独更改任何内容: am start -n com.android.settings/.TetherSettings 我发现的 tethe...

3  如何为rooted设备安装其他终端命令的捆绑?  ( How to install bundles of additional terminal commands for rooted devices ) 
我最近扎根了HTC野火S设备并闪过Android 4.1.2 AOKP果冻豆类自定义ROM。一个好处是我现在可以使用终端。 我有点习惯于在台式机上使用终端仿真器,但从中从未在Android设备上做过。我注意到没有找到一些命令,例如: $ tree /system/bin/sh: tree: not found ...

1  如何调查内存使用量?  ( How do i investigate the memory usage ) 
我是一个micromax a74,with(rooted)Android 4.2.2。最近我面临着一些应用程序的崩溃并开始分析RAM的使用。 设置&gt; apps&gt;运行没有帮助: 有时我发现只有2 MB免费! 我想知道哪个应用程序正在消耗内存? 我还尝试过 top -n 1 -m 8 : 但我...

3  手动安装Split APK  ( Install split apk manually ) 
最近我必须知道一个名为split apks的东西,并发现切片作为无效的apk文件,只有基础是。不幸的是,这意味着通常的默认包安装程序无法处理此操作,因此我必须知道另一件名为SAI的东西,一个拆分APK安装程序,能够与或没有root工作。然而,好奇,我想知道它是如何在内部工作的,并开始做一些研究。我没有走得太远,但我必...

9  如何在SD卡上找到交换分区的路径名?  ( How to find the pathname of the swap partition on sd card ) 
作为 < / a>警告,你不应该在错误的分区上启用交换,或者您可以销毁您的手机: 在我们进一步进一步之前好的!之前的手机有一个分区布局,其中MMCBLCK0是SDCard(外部)我们的手机使用MMCB1CCK1用于外部SD。这很重要,因为如果使用应用程序,它可能会预设使用mmcblck0作为交换分区。使用此设置将导...

7  如何使用adb更改“首选网络模式”而无需重新启动?  ( How to change preferred network mode using adb without reboot ) 
我正在尝试将手机的(cm 12,股票4.2,rooted)首选的网络模式从"gsm / wcdma" (0)更改为"WCDMA仅" (2),反之亦然(可以有其他模式也是)仅使用命令行。基于这个答案我可以使用命令将相关变化与 Settings.db 进行相关变化: adb shell su settings...

3  我应该在哪里安装Toybox?  ( Where should i install toybox ) 
我拥有一个rooted三星galaxy s继承4g运行股票和roid4.1.2。 如果您有Android 6.0"Marshmallow" 或更好,那么您有 toybox 。这是一包命令行工具,为有时使用终端仿真器的高级用户提供方便。不幸的是,Android 4.1.2不包括Toybox。相反,它包括一些与使用不太好...




© 2022 it.wenda123.org All Rights Reserved. 问答之家 版权所有