You are not logged in.

#1 2025-11-15 21:38:26

fez
Member
Registered: 2025-11-15
Posts: 2

[SOLVED] cannot ssh when ufw is enabled despite rules being set corr..

i cannot connect to my server through ssh when ufw is enabled. ive reset ufw several times just to make sure the appropriate port is open.

a bit more information: i set a custom ssh port in /etc/ssh/sshd_config (obfuscated in below text to be port "22", though when actually trying this with port 22 the issue persists regardless.) ive also put my desktop user's ssh key into the server user's .ssh/authorized_keys file so i dont have to use a password to gain ssh access from my desktop.

(server) "ss -tnlp | grep :22"  output:

 LISTEN 0      128          0.0.0.0:22     0.0.0.0:*          
LISTEN 0      128             [::]:22         [::]:*          

(server) "ufw status" output:

Status: active

To                         Action      From
--                         ------      ----
22                     ALLOW       Anywhere
22 (v6)             ALLOW       Anywhere

(host) "ssh -p 22 user@server" output (when ufw is enabled on the server):

ssh: Could not resolve hostname server: Name or service not known

host connects without issue when ufw is disabled.

im very lost, any help would be appreciated. even if the suggestion is to reset the server and redo everything, if itll work ill appreciate it. smile

Last edited by fez (2025-11-16 01:45:47)

Offline

#2 2025-11-16 01:28:01

archaea
Member
Registered: 2025-10-20
Posts: 20

Re: [SOLVED] cannot ssh when ufw is enabled despite rules being set corr..

fez wrote:

ssh -p 22 user@server" output (when ufw is enabled on the server):

ssh: Could not resolve hostname server: Name or service not known

How is your system intended to determine what IP "server" resolves to?

fez wrote:

(server) "ss -tnlp | grep :22"  output:

On the server side, running ss without grepping might help diagnose:

ss -A inet -nlp

Offline

#3 2025-11-16 01:45:17

fez
Member
Registered: 2025-11-15
Posts: 2

Re: [SOLVED] cannot ssh when ufw is enabled despite rules being set corr..

i found a solution! i figured that ssh wouldve functioned as it did when ufw was off on the server, where ssh 'user@host' works with no additional configuration, however after associating the servers local ip with the hostname (in .ssh/config) im able to ssh with the firewall running.

ive come across this issue before, but i really didnt think it was the case here hmm.. my bad. thanks for your help! smile marking as solved

Last edited by fez (2025-11-16 01:51:39)

Offline

Board footer

Powered by FluxBB