How to change default port 2222 ?

Tommyhara

Verified User
Joined
Jul 25, 2014
Messages
162
Hello,

I want to change default port 2222 when login to Directadmin

Is it possible?

for example:

I used login use mydomain.com:2222

now I want to change whatever number for that port, i. mydomain.com:9999

If it can change this port, it can affect to Directadmin work?
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
14,146
Location
GMT +7.00
Yes. It is!

Run this to achieve the desired:
Code:
cd /usr/local/directadmin/conf/
vi ./directadmin.conf
in the file find the line with
Code:
port=2222
change it to something you want, for example
Code:
port=9999
save, exit and restart directadmin
Code:
killall -9 directadmin
/etc/init.d/directadmin start
Make sure to open port 9999 with firewall and try to access Directamin in a browser.
 

Tommyhara

Verified User
Joined
Jul 25, 2014
Messages
162
Thanks Alex for great tips!

I have 2 questions more

1/ where and how to check port 9999 is disabled or enabled? ( I also installed csf)

2/ After changed to a new port (9999), do I need to close port 2222 and it can be accessed by others)? how to close a port?
 
Last edited:

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
14,146
Location
GMT +7.00
Open and update /etc/csf/csf.conf. Change 2222 to 9999 in the following lines:

TCP_IN=
TCP6_IN=
PORTS_directadmin=

save, exit and restart csf:

Code:
csf -r
to see whether or nor port is opened you can run:

Code:
csf -g 9999
results of the command is rather clear. It should show near similar to this:

Code:
# csf -g 2222

Chain            num   pkts bytes target     prot opt in     out     source               destination
INPUT            26     585 28520 ACCEPT     tcp  --  !lo    *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:2222


OUTPUT           36       0     0 ACCEPT     tcp  --  *      !lo     0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:2222




ip6tables:


Chain            num   pkts bytes target     prot opt in     out     source               destination
INPUT            22       4   240 ACCEPT     tcp      !lo    *       ::/0                 ::/0                state NEW tcp dpt:2222


OUTPUT           31       0     0 ACCEPT     tcp      *      !lo     ::/0                 ::/0                state NEW tcp dpt:2222
 

Tommyhara

Verified User
Joined
Jul 25, 2014
Messages
162
Open and update /etc/csf/csf.conf. Change 2222 to 9999 in the following lines:

TCP_IN=
TCP6_IN=
PORTS_directadmin=
Seem these configs are for CSF

If I disabled csf, then I only use tips in your first post, right?

It's enough for Directadmin to run with new port?

and change port, will it reduce "attempts login" from bots?


Sorry because I asked more questions :)



Thanks Alex!!
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
14,146
Location
GMT +7.00
Might reduce and might not reduce. That depends on what services are brute-forced. SMTP? POP? IMAP? FTP? If directadmin is the subject of all the attacks, then it should help.

It's enough for Directadmin to run with new port?
All the steps are in the first reply and they are sufficient. Of course if you use any other applications, scripts which communicate with directadmin then you should point them to the correct port.
 

mitra

New member
Joined
Dec 17, 2016
Messages
1
problems with ssh for change login port for directadmin

Yes. It is!

Run this to achieve the desired:
Code:
cd /usr/local/directadmin/conf/
vi ./directadmin.conf
in the file find the line with
Code:
port=2222
change it to something you want, for example
Code:
port=9999
save, exit and restart directadmin
Code:
killall -9 directadmin
/etc/init.d/directadmin start
Make sure to open port 9999 with firewall and try to access Directamin in a browser.
-------
hello i use xshell4
i can open the config file but i dont know how i can save the new command on it ?
please help me
 

Wanabo

Verified User
Joined
Jan 19, 2013
Messages
170
Try MC
Midnight Commander. Yum install mc.
If you're used to Windows Total Commander or in the old days Norton Commander, you'll find it easy to work with MC.
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
8,774
Location
LT, EU
Yes, you can use any port <1024 for it too, just make sure it's not used by any other service on your server :) For example, port 80 would be taken already by your WWW server.
 
Top