Have you ever wondered how to execute commands on your friends terminal without accessing his keyboard? Well now you can!!!
- Root or Sudo access on your Linux machine
- Debian or Debian based machine
A fairly new low-key piece of open source software has surfaced recently and it allows users with sudo access on Linux to run commands on another TTY session!!! To begin, this software is called ttyecho, and you can download its source code which can be found on my Github Scripts repository (here –> note I did not make ttyecho.c) or it can be found at its original source here.
To begin, you will need to be able to compile C code on your Linux system and a few other system requirements, luckily I have already created a script that automatically checks to see if your system meets the requirements and if not installs them. To run this script you must first have it downloaded from my scripts repository on GitHub, to do so go here and simply copy and past the script into a file called
runtty.sh. Next, we must make the script executable for future use, we can accomplish this by running
chmod u+x runtty.sh.
Finally, we can begin finishing this setup by simply running my script. To do so, all we have to run is
sudo ./runtty.sh, running my script as sudo will simply give it privileges to store your newly compiled version of ttyecho as a command…
Running the commands
After finishing the setup we can now run commands on another’s TTY session!!! Follow the steps below to run the commands:
- First, find the TTY you want to execute the commands as, to find the specific users terminal session please run
ps aux | grep screen | grep $USER
Note: Replace $user with the username
- Next, look for the TTY, it should look something like
pts/2, we will need this for the
$YOUR_TTYin the next step
- Finally, simply run
sudo ttyecho -n $YOUR_TTY "echo test"