Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
I'm new to ufw, and followed this link and entered exact command as instructed.
ufw allow ssh 2222
Since my SSH is 2222, I want to add that rule in, but I kept getting
ERROR: Need 'to' or 'from' clause
Any hints for me ? I don't want to get lock out.
asked Apr 23, 2021 at 15:11
41211 gold badge66 silver badges1818 bronze badges
The ufw man says:
Example rules using the simple syntax:
ufw allow 53
This rule will allow tcp and udp port 53 to any address on this host.
To specify a protocol, append '/protocol' to the port. For example:
ufw allow 25/tcp
This will allow tcp port 25 to any address on this host. ufw will also
check /etc/services for the port and protocol if specifying a service
by name. Eg:
ufw allow smtp
So if you say
ufw allow ssh
it is the equivalent of
ufw allow 22/tcp
In your case it would work if you put just
ufw allow 2222
ufw allow 2222/tcp
since I guess you don't need udp...
answered Apr 23, 2021 at 15:38
1,01444 silver badges1515 bronze badges
You must log in to answer this question.
Not the answer you're looking for? Browse other questions tagged