How I Control My PC from My Phone: A Guide Using Termux, SSH, and SSHpass
Category: Linux
Date: 9 months ago
Views: 905
Introduction
Hey there, fellow tech enthusiasts! Imagine having the power to control your PC right from the palm of your hand. Well, buckle up because I'm about to show you how I do just that using Termux, SSH, and SSHpass. Get ready to unlock a whole new level of convenience and productivity!
Setting Up Termux, SSH, and SSHpass
Install Termux: First things first, head over to the Google Play Store or F-Droid and install Termux on your Android device. It's a powerful terminal emulator that's perfect for our needs.
Install SSH: Once you've got Termux up and running, install the OpenSSH package using the package manager:
pkg install openssh
Install SSHpass: Additionally, install SSHpass, a handy tool for non-interactive SSH password authentication:
pkg install sshpass
Setting Up SSH on Your PC
Enable SSH: Now, let's head over to our PC running Arch Linux and enable SSH. If you haven't already, install the
openssh
package and start the SSH service:sudo pacman -S openssh
Configure SSH: To ensure secure connections, let's configure SSH by setting up SSH keys for authentication. This adds an extra layer of security and convenience.
Connecting Your Phone to Your PC
Find PC's IP Address: Open up a terminal in Termux and find your PC's local IP address using the
ifconfig
orip addr
command.Connect via SSH: With the IP address in hand, establish a connection to your PC from Termux using SSHpass. Use the following command, replacing
"mylinuxpassword"
with your actual password,myusername
with your username, and192.168.1.12
with your PC's IP address:ssh myusername@192.168.1.12
after the first connection with ssh, you can skip the part of the password prompt everytime using sshpass
like so:
sshpass -p "mylinuxpassword" ssh myusername@192.168.1.12
Executing Commands from Your Phone
Basic Commands: Start off by running some basic commands like
ls
,pwd
, anddate
directly from your phone. It's like having a mini Linux terminal in your pocket!Running Custom Shell Scripts: Take things up a notch by running your own custom shell scripts stored on your PC. Whether it's controlling music playback with
mpc
or snapping photos withffmpeg
, the possibilities are endless.
As always, I created a simple alias for this whole command, therfore making connecting to my pc as efficient as possible. As an Arch linux user, almost all the daily commands and programs I use are actually my proper shell scripts. So for me, almost all the functionality of my pc can be used with this small command through my phone
Conclusion
By harnessing the power of Termux, SSH, and SSHpass, I've transformed my phone into a remote control for my PC. The convenience and productivity gains are undeniable, and I can't imagine going back. Give it a try, and unlock a whole new world of possibilities!
0 Comments, latest
No comments.