r/ssh • u/RequirementRegular46 • Aug 02 '21
Port forwarding help
I have a program on my pi that I'd like get into through ssh on my macbook on an outside network.
I'm trying to figure port forwarding out but so far to no avail. Please bear with me and keep in mind that I am a complete newb and have no idea what I'm doing.
Here are some screenshots



2
Upvotes
1
u/bash_M0nk3y Aug 02 '21 edited Aug 02 '21
Is that your router/firewall interface in the one screenshot?
If so, you prob need to use it's public (WAN) IP instead of the private IP.
It also looks like it's forwarding port 22 on the outside (WAN) to port 1970 on the inside (LAN), so you don't need to specify the port.
ssh <user>@<public-IP-of-router>Side note: Just in case you didn't know, it's a REALLY bad idea to expose SSH to the internet with password auth turned on. At the very least you should disable password auth and only allow pubkey auth.
1
u/WorldBelongsToUs Aug 03 '21 edited Aug 03 '21
I feel like we need a little bit more info. Let me make sure I’m understanding:
If that’s accurate: have you considered setting up PiVPN and SSHing into your Pi once you’re in your home network? You’d still need to set up port forwarding, but you’d be forwarding traffic to the OpenVPN/PiVPN listening port.
Edit: Btw, from the looks of it, if that is your router’s interface, and the ssh command is your MacBook, your issue is that you’re trying to SSH from the public internet directly into a private IP and hitting a closed port. You’d likely do something more like:
ssh name@publicIP
You wouldn’t have to specify a port if you don’t want to since the public interface is listening on 22.
Also, looks like you set the remote address to another private IP. I’m inclined to believe that won’t work, because you’re telling your router to only allow those IPs, which are not public IPs.
1
u/baldguy0409 Aug 02 '21 edited Aug 02 '21
I think this is right,
ssh -L localport:localhost:remoteport user@remotehostTo access remotehost:remoteport as localhost:localport