• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 462
  • Last Modified:

Change ssh port

How could i change ssh port of my linux cent os 5.4 final
0
CahitEy
Asked:
CahitEy
  • 3
  • 3
1 Solution
 
fosiul01Commented:
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
0
 
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 0.0.0.0
#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

0
 
fosiul01Commented:
Remove #  and change to anything like

Port 222

but change the iptables rules first. and restart iptables


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


upper rules will allow only that ip to allow your ssh


0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
CahitEyAuthor Commented:
ok then how could i restart ssh service to activate new port
0
 
fosiul01Commented:
service sshd restart
0
 
CahitEyAuthor Commented:
You are a life saver :D

one last question for today if you have time

http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Apache/Q_26022199.html#a31887500
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now