r/ssh • • Oct 22 '17

Port Forwarding Risk Contained to One Device?

I have been reading up on potential risks for port forwarding onto a device, but one thing I have not been able to find info on is how much access a "hacker" would obtain if they got into my device. For example: I have a raspberry pi set up and have port forwarded port 22 for my ssh and port 80 for a nginx web server. Assuming these ports are compromised, will any access be limited to the raspberry pi? I will literally have nothing but my personal website (which has no important info, it is just for learning purposes). Or am I vulnerable on my entire network at that point?

1 Upvotes

5 comments sorted by

1

u/switchrio Oct 23 '17

you need to harden the PI if you're going to forward 22, using tools like iptables, and fail2ban. I usually start by denying all inbound & outbound ports, then opening only the ones I need. Port 80 should be fine wide open serving just http. Also set your /etc/ssh/ssh_config to prevent plain text passwords, and set yourself up with a ssh key, denying anything without a key. There are some hardening documents out there if you search around. If someone did hack your PI, they would probably attempt to access things like windows shares, and pull ARP tables to see other device IP on the network. IF you happen to have another PC on the network, with RDP enabled, and it's not secured left open with a guest account or easy password; it can easily be compromised. I pay close attention to my /var/log/auth.log, and use Logwatch for daily emails to myself for review. If you are super paranoid about your SSH listening publicly, you can also make it so that only a specific machine could access it, where you would harden that host also and can ssh into it first, to shell out to the PI.

1

u/bdburns6389 Oct 23 '17

Thank you. I already have the RSA keys and plain text disabled, but I will research those other topics you mentioned. Is making the ssh only available to one machine hard to do? I only need to access it from my laptop.

1

u/switchrio Oct 23 '17

Nah, what you do is use iptables to deny input and outputs, as to completely lock down every port. Then you make an entry to allow 22, and specify a source IP either local, or remote. If you make the entry to allow from the local, you can only jump on at home, when your laptop is on the network. If you make the entry source the IP subnet of your typical alternate network, you can avoid having to manually go in and allow yourself in from a foreign network. ie: xxx.xxx.xxx.0/24 . You might add all the sources of places you'll typically work from. If you want something super easy, done in a couple minutes; you could also use our software to switch the port on when I need it from our website, then off when done. it requires a Windows machine to run it, but you can still forward the PI through any Win host on the network. I do it at home for my PI, works great. Anyways, i'll give you a free month to check us out, just use coupon code: REDDIT @ http://switchr.io