What Ports do I need to keep open to access my SSH Server with non-default Port

  • 5,000
  • Tác giả: admin
  • Ngày đăng:
  • Lượt xem: 5
  • Tình trạng: Còn hàng

There are a few things you need đồ sộ setup at minimum đồ sộ have SSH working, and this configuration then changes down the line depending on what you wanna vì thế.

Lets assume for everything right now, that you are on your own internal network and are keeping all the values mặc định, for now until we know this works. then we will continue with an advanced config.

For now, no port forwarding is needed, that is the final step. For now we only need đồ sộ know the service is enabled, what IP the remote machine has, and on what port the ssh-server daemon listening, and if the remote firewall is blocking incoming requests for SSH.

step 1 -install and enable the openSSH-server service (on the remote machine)

step 2-Disable firewall (on the remote machine)

If you're not 100% sure if you disabled the remote firewall or not, do:

sudo service ufw status

there you will see its status, when active, let's disable it for now.

sudo service ufw disable

If you have just installed openssh-server and you didn't change the config, the mặc định port is mix đồ sộ 22. If you have changed the SSH config đồ sộ listen on another port, restarting ssh-server service is required. The spawned SSH process is still cached in memory and will only start serving on a different port the moment a new SSH-server daemon process is spawned.

As such, do:

sudo service ssh restart

now move over đồ sộ the client PC. Ping the remote machine. That is step one for basic connectivity, but ping is a bad tool for testing protocol or service issues. They exist on different OSI layers. now open your ssh client, this can be putty or something else, or just a terminal window in linux works fine too.

After doing above steps, this should really work đồ sộ connect, if not, repeat previous steps or ask more questions.

If you kept things mặc định, and its working, now would be the time đồ sộ switch over the ssh port if desired. so sánh for example let's say you changed the port from 22, đồ sộ 2200 in the ssh-server config on remote machine, the next step would be đồ sộ enable the firewall on remote machine, but this time add some rules after. As soon as the rules are loaded-in and the firewall is enabled, for good measure restart ufw service and ssh service once more, then try đồ sộ connect.

If you changed the SSH port from 22 đồ sộ 2200, you would have to

ALLOW a rule for TCP rule for PORT 2200 from ANY adress

it will add the same rule for ipv6 automatically.

if you are comfortable turning off UFW on remote machine for now that is fine too.

Now that SSH is working on your local network, you can start configuring remote access. This is different for each router but about the same process.

Find in the thực đơn of your modem/router a category for port forwarding, usually under firewall/internet or IP configuration. when you found port forwarding, what you wanna vì thế is forward an external port (this can be any port, comes down đồ sộ personal preference and security) for example a random port, 8422. This would be the remote port that we connect đồ sộ whenever we are outside. We forward this port, đồ sộ the internal port 2200 that we have mix on the machine.

so instead of internal IP and port, now we use the external IP adress, and the external port. this is now configured đồ sộ tunnel directly đồ sộ the 2200 port on internal network, and should be reachable. if this last step gives you issues, restart modem/router and remote server completely. if that still doens't work, but the internal ssh does, you can be sure the configuration is not yet correct. Permission denied error sounds lượt thích you're trying đồ sộ access SSH on the wrong port. so sánh you can reach the machine, but the port that is requested for SSH is not serving that, so sánh the permission is denied.

Hope this helped.