How to change default port 2222 ?

Tommyhara

Verified User
Joined
Jul 25, 2014
Messages
187
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?
 
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.
 
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:
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
 
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!!
 
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.
 
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
 
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.
 
Is it possible to use a priviliged port for DA ?

Thanks
 
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.
 
I'm trying to change port 2222 in the path: /usr/local/directadmin/conf/directadmin.conf

and asks for this password: This file is marked as safe. Root password required to edit. I entered the directadmin panel password and it doesn't work. What would that password be?
 
I'm trying to change port 2222 in the path: /usr/local/directadmin/conf/directadmin.conf

and asks for this password: This file is marked as safe. Root password required to edit. I entered the directadmin panel password and it doesn't work. What would that password be?
as the message says, you cannot use DA pw, you must use your (linux) root password.
 
Back
Top