How to Forward Port 22 to allow SSHing from outside LAN [duplicate]

Solution 1:

This is quite a straightforward operation and the principles of port forwarding (or where to find the info) have been pointed out by others, but just a few more tips:

1) Port forwarding is a feature of your 'outside world' connection device - maybe a cable or ADSL (broadband) router so you'll need to check its docs - probably it has a Web interface for configuring this.

2) Every man and their dog knows that the ssh port is number 22, so if this port is open to the outside world, you will get a lot of attention from elsewhere trying to login using user/password tables etc. To help with this, see if your router supports forwarding alternate ports so, for example, you can instruct it to forward (say) external port 40822 to your computer's port 22 and then you would ssh connect to port 40822.

3) In the long run, if you are going to access your computer regularly from the outside world, you should read up about setting up OpenVPN (or another VPN system compatible with your OS) to give you a secure tunnel into your machine.

Solution 2:

Your home internet connection will be handled by an ADSL router or a Cable router or something similar. When people talk about port forwarding in the context you're referring to they usually refer to the firewall / NAT section of your home router / modem.

If you want to be able to SSH into your machine at home, you have to tell your home router / modem to accept data on port 22 and send it to a specific computer on your network (your PC).

This site has some very annoying adverts, but also, a lot of guides for port forwarding by router version which since you didn't tell us what you have, is probably a good place to start.

Additionally, you don't tell us what OS your PC is using, but you'll need to ensure the firewall on your PC allows incoming connections on port 22 (whether that's iptables on Linux or Windows Firewall, or whatever else you're running).