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: 3.140.195.142

User Agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)

Language:

Latest Posts

Iowa City Weather

Overnight

42 ˚F / 46 ˚F

Friday Night

41 ˚F / 50 ˚F

Saturday Night

35 ˚F / 48 ˚F

Sunday Night

32 ˚F / 44 ˚F

Monday Night

30 ˚F / 35 ˚F

Tuesday Night

24 ˚F / 31 ˚F

Wednesday Night

19 ˚F / 28 ˚F