LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-10-2010, 10:55 PM   #1
sandeepthug
Member
 
Registered: Nov 2008
Posts: 38

Rep: Reputation: 15
change ssh port


Hi i need to change ssh port on the servers including centos and ubuntu


when i make changes to /etc/ssh/sshd.config and change the port to something else

restart sshd

then i can determine that port 22 is not working
but ssh does not connect to new port
it says "no route to the host"
Please help

sandeep
 
Old 03-10-2010, 11:06 PM   #2
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
Your firewall on the server is probably blocking the new port. You need to modify your firewall to allow access to the new port, and close access to port 22.
 
Old 03-11-2010, 12:02 AM   #3
sandeepthug
Member
 
Registered: Nov 2008
Posts: 38

Original Poster
Rep: Reputation: 15
how do i modify the server firewall
i don't know iptables


thanks
sandeep
 
Old 03-11-2010, 12:33 AM   #4
mario.almeida
Member
 
Registered: May 2008
Location: India
Distribution: Ubuntu 10.04, CentOS, Manjaro
Posts: 179

Rep: Reputation: 27
Hi,

1) Is the server and the PC you want to connect are in the same network?
2) What is the OS on the server?
 
Old 03-11-2010, 12:40 AM   #5
sandeepthug
Member
 
Registered: Nov 2008
Posts: 38

Original Poster
Rep: Reputation: 15
yes they are on the same network

i am using ubuntu 9.10 and centos 5.3
 
Old 03-11-2010, 12:53 AM   #6
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
Are you able to disable the firewall to confirm it is causing the problem? Obviously if this machine is facing the internet then this isn't a great idea.

I don't know Ubuntu, but you can control the CentOS firewall using the GUI without having to know iptables. Go to System, then Administration and you should find "Security Level and Firewall". If you don't have access to the GUI, then run system-config-security-level-tui from the command prompt.
 
Old 03-11-2010, 02:07 AM   #7
mario.almeida
Member
 
Registered: May 2008
Location: India
Distribution: Ubuntu 10.04, CentOS, Manjaro
Posts: 179

Rep: Reputation: 27
Hi,

On the server do the following

Post the output of
Quote:
cat /etc/sysconfig/network-scripts/ifcfg-<iface>
replace <iface> with the actual interface i.e eth0 or eth1 etc..

Verify if sshd is started with the new port
Quote:
netstat -pant | grep ":<new ssh-port>" | grep LISTEN
Stop iptables on the server
Quote:
/etc/init.d/iptables stop

On the Desktop
How have you configured your network settings command line or GUI

Verify your network settings with the below command
Quote:
ifconfig
I hope you are trying to connect to the server by mentioning the new port as below
Quote:
ssh -p <new ssh-port> <server-ip>
 
Old 03-11-2010, 03:43 AM   #8
sandeepthug
Member
 
Registered: Nov 2008
Posts: 38

Original Poster
Rep: Reputation: 15
Hi All
i tried to change the port once again from /etc/ssh/sshd-config
changed it and
restarted sshd
everything works like charm

i don't know what was happening yesterday

thanks all
 
Old 03-11-2010, 06:35 AM   #9
nowonmai
Member
 
Registered: Jun 2003
Posts: 481

Rep: Reputation: 48
Just FYI - 'no route to host' is a networking problem... most likely that the IP specified is not on the same subnet. If the problem was a port or firewall issue, the message would have been 'connection refused'.
 
1 members found this post helpful.
Old 03-11-2010, 04:04 PM   #10
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
Of course it is. I should read the OP more carefully
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change SSH to diffrent port kamtono Linux - Security 5 08-13-2009 06:55 PM
why I don't change the port about ssh beyond911 Linux - Software 7 08-18-2007 12:53 AM
ssh change port Longinus Linux - Newbie 14 12-16-2006 03:34 PM
Change ssh port number israel Linux - Software 2 08-30-2006 05:18 AM
Change SSH Port? flamesrock Linux - Software 6 10-02-2004 07:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration