Is it possible to run an ssh shell on an android phone when the phone is remotely connected but on 3G? I have my phone remote and sending data over 3G but I might want to change something on it. I have considered

1) the phone receiving text back from an http request and riunning it as a connad 2) running an ssh shell on the phone anything else?


  • While it's technically possible, a general answer cannot be given – as that very much depends on your provider. Some providers allow for that, others have the (incoming) ports blocked. If blocked, this is only possible with the Android device establishing the connection to begin with – not the other way around.
    – Izzy
    Nov 27, 2014 at 16:11

5 Answers 5


One way to make your Android machine accessible via WAN SSH access (as in connecting from anywhere) would be to create a reverse SSH tunnel from your Android machine to some machine that is always online. It can be your Desktop machine behind a NAT router (most common case). Then you forward that same port from the Router to your Desktop machine. This is what you get:

Android ==REVERSESSHTUNNEL==> Desktop <==PORTFORWARD== Router with public IP

Both the reverse SSH tunnel and port forward from the Router can be done on any high number port, but to avoid making a port numbering mess just pick one high number, above 1024, and stick with that. So you get for example:

Android:3331 ==REVERSESSHTUNNEL==> Desktop:3331 <==PORTFORWARD== Router:3331 with public IP So what happens when you SSH into your router's IP at port 3331 is that your router forwards the connection to the Desktop at port 3331 and the Desktop (because the connection from the android device to the desktop, which looks like it's in the wrong direction, is in fact REVERSED, so it's as if the Desktop is actually connected to the android device) will forward the connection to the Android device at port 3331. So your SSH connection will go from Whatever => Router => Desktop => Android.

This will work because your ISP will not block your Android from SSHing into your desktop while it would block you from SSHing into your Android from your Desktop or anywhere else on the default port. So we use that fact, connect "the wrong way" and then reverse the connection and get the same thing as if though we connected the "right way".

Don't forget to make the Android machine's SSH app listen at port 3331 or make the reverse tunnel open the port 22 on the Android machine's side.

  • A fantastic real world example of ssh tunneling. This answer needs to be part of any place talking about ssh port forwarding and/or tunneling.
    – Krista K
    Mar 4, 2020 at 16:55

As others have said, technically yes it is possible but there is a chance that your carrier does not allow connections to the relevant port.

Try SSHDroid, that should do what you're asking for. If it doesn't work then you know its because of your carrier. https://play.google.com/store/apps/details?id=berserker.android.apps.sshdroid


I don't think it would be very possible for a lot of carriers based on the fact the ports would most likely be closed. If it were over WiFi/local, yes. You could easily use Tasker to read texts and perform actions though I could imagine.


If you prepare your phone acordingly, yes, its possible. I've done it many times. I wrote an App which does a port forwarding to my Server. (adb over wifi port). All you need to do is to log on to the server and you'll see the device connected as it would be plugged in using usb. I even did further port forwarding to my local machine. Works well, but if the phone is on the ride, you may get several connection losses.

It works cause the phone is connecting to the server and not the other way round (blocked by firewall in most countrys).

Good luck!


If you have a VPS cloud it is possible. Get cheap cloud from arubacloud.com.

First off, log in to your remote server and open /etc/ssh/sshd_config. If it does not already exist add the line:

GatewayPorts clientspecified

Then restart the SSH daemon:

sudo /etc/init.d/ssh restart
# or
sudo service sshd restart

Back on your Android, start your development server or any thing you want to access from anywhere and then in JuiceSSH terminal run the following:

 ssh -N -R :3000:localhost:8182 root@vpsipadress

On asking type VPS user's password. That's it. Where Android's local port is 8182. Anyone now can access it vpsipadress:3000.

You can apt-get install sshpass and use passwords of servers in this command:

sshpass -p Password ssh -N -R :3000:localhost:8182 root@vpsipadress


autosh, cron ---- crontab -e and auto.sh, too many options.


The Best thing on Android is that install Gnuroot Debian. Best Linux for non rooted Adndroid. Install ssh and sshpass. And in /etc/rc.local add this command :

while true; do sshpass -p YOURPASSWORD ssh -N -f -R :3000:localhost:8182 USER@YOURHOST-OR-IP; sleep 3; done

rc.local will make sure to execute this command on startup. And on disconnect or any kind of change in internet/network, the loop script will try to reconnect it every 3 seconds.

You can also make auto.sh script:


while true; do sshpass -p YOURPASSWORD ssh -N -f -R :3000:localhost:8182 USER@YOURHOST-OR-IP; sleep 3; done

chmod +x will make it executeable.

sh auto.sh

If rc.local won't help install cron:

apt-get install cron
crontab -e

add command: @reboot sh auto.sh. shif+zz to save. This cron job will do it on startup.

  • The best thing u can do on android is Feb 2, 2017 at 3:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .