Is it possible to SSH to linux server behind NAT

5,034

Solution 1

The standard port for ssh is 22.

You have to tell your router to forward a port (22, tcp) to your linux machine's IP. This is usually in a section called 'NAT' or 'Servers' in your router's configuration.

Most OSs have a firewall installed as standard. So you may have to open port 22 on your server machine's software firewall as well. (try 'ipkungfu' for a fairly simple interface to set up a linux firewall)

Solution 2

You have to use DNAT.

Solution 3

Reverse SSH if you dont have access to the router

Share:
5,034

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    I have linux server behind NAT but i can farward the port to LAN computer.

    How can do that so that at least i can ssh

  • user1364702
    user1364702 about 14 years
    Don't forget the part about setting your server to a static IP internally. Otherwise you'll risk eventually having the machine "disappear" after coming back up from a power outage.
  • user1364702
    user1364702 about 14 years
    A static IP outside the DHCP pool, that is.
  • AFA Med
    AFA Med over 6 years
    What about if we have two or more machines behind the NAT and we want to be able to SSH them all.
  • nightsurgex2
    nightsurgex2 over 6 years
    you can assign a different port on your firewall and forward it to the second machine e.g. incoming tcp on port 10022 (or any other port you like) goes to internal ip of second ssh server port 22 (depending on your firewall you can set the port of the internal machine or configure your ssh to listen on port 10022)