LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   ssh: connect to host 192.168.168.94 port 22: Connection refused (https://www.linuxquestions.org/questions/linux-networking-3/ssh-connect-to-host-192-168-168-94-port-22-connection-refused-4175443648/)

vjramana 12-31-2012 10:56 PM

ssh: connect to host 192.168.168.94 port 22: Connection refused
 
I am using ubuntu 11.10 as my desktop and centos 6 as a server.

I used to connect from ubuntu to centos using ssh. It was fine all the while.

Start from today, i can not ssh to my centos server.

When I type
Quote:

ssh vijay@192.168.168.94
Quote:

ssh: connect to host 192.168.168.94 port 22: Connection refused
I have tried to uninstall and re-installed openssh-server.
Upon re-install I can ssh to the server but for a while only ( about 20 minutes only ).
Suprisingly after that I get

Quote:

write failed broken pipe ssh
then I can not ssh anymore. Getting the same message
Quote:

ssh: connect to host 192.168.168.94 port 22: Connection refused

I tried this command
Quote:

ssh 192.168.168.94 -vvv
I get
Quote:

vijay@glycosim:~$ ssh 192.168.168.94 -vvv
OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.168.94 [192.168.168.94] port 22.
debug1: connect to address 192.168.168.94 port 22: Connection refused
ssh: connect to host 192.168.168.130 port 22: Connection refused
I dont know how to solve this matter.
Can I get any help?

Thanks so much in advance.

bijo505 01-01-2013 05:21 AM

Hi,

It seems that sshd service is not running on the server.

Code:

#/etc/rc.d/init.d/sshd status
if it is running check the configuration file and find out the ssh listening port or run the following, that will help you to find out the listening port

Code:

# netstat -natlpe | egrep -i ssh
And after that enabling the batch mode by adding the following in your ssh user config file

Code:

vi  ~/.ssh/config
Host *
ServerAliveInterval 300

After this also, if you are not able to connect, disable iptables and then try to connect.

Code:

#/etc/rc.d/init.d/iptables stop
Also please have a look at the following URL
http://www.cyberciti.biz/faq/centos-ssh/
--
Thanks,
Bijo

vjramana 01-01-2013 06:14 AM

Hi bijo505,

for your first command I get

Quote:

openssh-daemon (pid 3276) is running...
for the second command I get

Quote:

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 14338 3276/sshd
tcp 0 0 192.168.168.xxx:22 192.168.168.yy:58041 ESTABLISHED 0 21217 4275/sshd
tcp 0 0 192.168.168.xxx:22 192.168.168.yy:58044 ESTABLISHED 0 25012 5181/sshd
tcp 0 0 :::22 :::* LISTEN 0 14336 3276/sshd
(simply changed the IP numbers with xxx and yy)


For the third change as below
Code:

vi  ~/.ssh/config
Host *
ServerAliveInterval 300

I dont have config file at the location you mentioned above.
Shall i create one?

Thank you

bijo505 01-02-2013 06:56 AM

Hi,

You can create that config file. Are you able to ssh to the server from the server and any other hosts now? Can you please check the sshd_config file and if you can attach the same here, it will help to have a look at the config.
--
Thanks,
Bijo

vjramana 01-03-2013 02:51 AM

Hi Bijo,


I created the config file and changed its mode as below
Quote:

chmod 600 ~/.ssh/config
Now it is working fine.

Thank you so much for your help.
Regards


All times are GMT -5. The time now is 07:50 PM.