Change ssh port

How could i change ssh port of my linux cent os 5.4 final
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

in /etc/ssh/sshd_config

change the port

Port 22

to anything you like

then restart sshd damon
dont forget to add that port in iptables
also only allow certain ip to connect to the servier via iptables

dont allow it to every one. its a security risk
CahitEyAuthor Commented:
file is seems like the given below will i remove the ->  #  
then i will change it to another port and i will configure iptables before doing this is this right ?
#Port 22
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

Open in new window

Remove #  and change to anything like

Port 222

but change the iptables rules first. and restart iptables

-A RH-Firewall-1-INPUT -s -p tcp -m tcp --dport 222 -j ACCEPT

upper rules will allow only that ip to allow your ssh

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

CahitEyAuthor Commented:
ok then how could i restart ssh service to activate new port
service sshd restart

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CahitEyAuthor Commented:
You are a life saver :D

one last question for today if you have time
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.