SSH

Reverse SSH Notes

2024/02/28

Setup REveres ssh

  1. Make sure SSH is installed on both machines
sudo apt-get update
sudo apt-get install openssh-server
  1. On your hidden machine run
ssh -f -N -R 2222:localhost:22 someuser@example.com  -i ~/.ssh/id_rsa_rev

This command opens an SSH connection to greggallardo.com (the machine exposed to the internet) sets up aa tunnel back to localhost (the home machine) on port 22 (the standard SSH port).

  • -fand -N : Tells SSH to go into the background and not execute any remote commands, respectively.
  • -R : Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side.
  1. make it persist with cron
crontab -e

tell it to use

@reboot sleep 60;ssh -f -N -R 2222:localhost:22 someuser@example.com  -i /home/locakuser/.ssh/id_rsa_rev

Connect from the outer machine

  1. SSH into your remote machine
 ssh froderick@example.com
  1. Onec inside, you can reverse ssh to the hidden machine with
ssh -p 2222 localuser@localhost

About Me

Greg Gallardo

I'm a software developer and sys-admin in Iowa. I use C++, C#, Java, Swift, Python, JavaScript and TypeScript in various projects. I also maintain Windows and Linux systems on-premise and in the cloud ( Linode, AWS, and Azure )

Github

Mastodon

YouTube

About you

IP Address: 34.236.191.0

User Agent: CCBot/2.0 (https://commoncrawl.org/faq/)

Language: en-US,en;q=0.5

Latest Posts

Iowa City Weather

Today

-- ˚F / 61 ˚F

Sunday

71 ˚F / 54 ˚F

Monday

64 ˚F / 46 ˚F

Tuesday

76 ˚F / 54 ˚F

Wednesday

76 ˚F / 56 ˚F

Thursday

72 ˚F / 51 ˚F

Friday

67 ˚F / 47 ˚F