How can I use Macrodroid to connect to remote SSH and execute commands?

aitn

Member
Hello,

I’m looking for a way to connect to remote SSH and then execute commands, for example:

1. SSH user@host.com password
This will connect to my remote SSH passing username, password, host name.
2. mkdir /testing
This will create a folder called “testing” once it’s connected.

Any suggestions how could that be accomplished with Macrodroid? @Dimlos

Thank you.
 

Endercraft

Moderator (& bug finder :D)
You would need a SSH client that supports locale plugin. Else you can't really do anything with MacroDroid.
 

aitn

Member
You would need a SSH client that supports locale plugin. Else you can't really do anything with MacroDroid.
What kind of SSH client that supports locale plugin? Got an example?

Why can’t you do anything with Macrodroid but with PHP you can do this:
shell_exec("SSH user@host.com mkdir /testing");
Can’t you do the same with Macrodroid?
 

aitn

Member
Hello,

I’m looking for a way to connect to remote SSH and then execute commands, for example:

1. SSH user@host.com password
This will connect to my remote SSH passing username, password, host name.
2. mkdir /testing
This will create a folder called “testing” once it’s connected.

Any suggestions how could that be accomplished with Macrodroid? @Dimlos

Thank you.
@Dimlos
How do I make a JuiceSSH (or another SSH client - @Endercraft ?) script shortcut that does the following:

1. SSH user@host.com password

2. mkdir /testing

I think I can then use Macrodroid to launch the shortcut but the problem is Macrodroid is quite limited to what shortcuts it can open.

Thank you.
 

Endercraft

Moderator (& bug finder :D)
What kind of SSH client that supports locale plugin? Got an example?

Why can’t you do anything with Macrodroid but with PHP you can do this:
shell_exec("SSH user@host.com mkdir /testing");
Can’t you do the same with Macrodroid?
I don't have an example.

MacroDroid can't do the same as PHP because it's not PHP, it's an Android automation app..
 

aitn

Member
I don't have an example.

MacroDroid can't do the same as PHP because it's not PHP, it's an Android automation app..
There's a shell in every Android (mksh if not old) though most would install a more comfortable Linux environment using AnLinux or similar. JuiceSSH can be externally controlled though just how I don't know, but it has "snippets" (scripts) it can run which would be easy to setup and invoke (by MD or a shortcut) -- I don't know if they can be dynamic or externally created. Neither if MD can launch these script shortcuts.

Can’t Macrodroid invoke that shell?
 

Jacob L

Moderator (Lawsonator)
MacroDroid is compatible with Tasker plugins. MacroDroid has a store for compatible plugins, it's the black rule. You can search SSH there and it returns quite a lot of results
 

aitn

Member
Hello,

I’m looking for a way to connect to remote SSH and then execute commands, for example:

1. SSH user@host.com password
This will connect to my remote SSH passing username, password, host name.
2. mkdir /testing
This will create a folder called “testing” once it’s connected.

Any suggestions how could that be accomplished with Macrodroid? @Dimlos

Thank you.
@Dimlos you can try the app https://github.com/tberghuis/SshCommandRunner and somehow get macrodroid to tap on entry
but do you think there is a cleaner way that is not UI Interaction dependent?
 

aitn

Member
MacroDroid is compatible with Tasker plugins. MacroDroid has a store for compatible plugins, it's the black rule. You can search SSH there and it returns quite a lot of results
Anything interesting that you found that you could recommend from the MD store?
 

aitn

Member
@Dimlos How can I use AutoTools SSH which is a plugin from João, the Tasker Dev to accomplish this? Will it be compatible with Macrodroid?
 

Endercraft

Moderator (& bug finder :D)
What about you try it yourself ?
I could tell you how to right now, but just try it knowing there is a Tasker/locale plugin action. If you want to learn then you need to try it yourself instead of asking for a complete solution on something that's not really related to MacroDroid.
 

aitn

Member
What about you try it yourself ?
I could tell you how to right now, but just try it knowing there is a Tasker/locale plugin action. If you want to learn then you need to try it yourself instead of asking for a complete solution on something that's not really related to MacroDroid.
I’m not that tech savvy 😢
 

Endercraft

Moderator (& bug finder :D)
It's nothing complicated, you have to click 4 times and you're on the configuration screen.
I rooted my old phone 2 days ago for example and everything went fine, it took 30 minutes of my life but it was worth it. I would say that it was pretty easy as long as you follow the steps correctly.
 

Dimlos

Well-known member
I was able to install openssh server on lubuntu and openssh on Termux and connect via SSH.
If I can do it with Termux, I should be able to do it with Termux:Tasker.

It depends on what you want to do with SSH, but I doubt if it is worth running it from MacroDroid since it requires some interaction.
 

Attachments

  • Termux.jpg
    Termux.jpg
    162.6 KB · Views: 1

Dimlos

Well-known member
I don't have much time right now to reply so much. You don't just want to create a directory, do you?
Please try to be more specific about what you actually want to do with SSH.
I'll look into it when I have time.
 

aitn

Member
I was able to install openssh server on lubuntu and openssh on Termux and connect via SSH.
If I can do it with Termux, I should be able to do it with Termux:Tasker.

It depends on what you want to do with SSH, but I doubt if it is worth running it from MacroDroid since it requires some interaction.
But if you use AutoTools SSH which is a plugin from João, the Tasker Dev to accomplish this
Will it still require UI Interaction? And does it work for you when you connect from it? What’s the exact Tasker/locale plugin action you use (screenshot)?
 

aitn

Member
I don't have much time right now to reply so much. You don't just want to create a directory, do you?
Please try to be more specific about what you actually want to do with SSH.
I'll look into it when I have time.
What if I use your macrodroid command to call the php server bat.php page that execute a batch file, or alternatively can I execute ssh from php?
I read that you could do this:

shell_exec("SSH user@host.com mkdir /testing");

But where do you enter the password? Will it work for php server that’s running on a windows 11?
 

Dimlos

Well-known member
UI interaction is not necessary with Termux either.
It is often necessary to execute a command, receive the result, see the result, and then execute another command, so MacroDroid is not suitable for that kind of use.
 

aitn

Member
UI interaction is not necessary with Termux either.
It is often necessary to execute a command, receive the result, see the result, and then execute another command, so MacroDroid is not suitable for that kind of use.
what’s the command in macro you used for it (got a screenshot)? does it open the termux app for it? what do you think about the php option?
 
Last edited:

Dimlos

Well-known member
I want you to be specific about what you actually want to do, and that will change whether you really need SSH.
Right now it doesn't even tell me which is the server or the client.
I'm running out of time, so I'll reply when I have time, so please write in detail by then.
 
Top