Solved

ssh connection refuse

Posted on 2009-07-10
30
841 Views
Last Modified: 2013-12-04
ssh connection refuse
0
Comment
Question by:1030071002
  • 11
  • 7
  • 3
  • +4
30 Comments
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 78 total points
ID: 24827713
check for firewall or ssh daemon / server not running
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 78 total points
ID: 24827732
check for firewall or ssh daemon / server not running
0
 
LVL 30

Accepted Solution

by:
Kerem ERSOY earned 186 total points
ID: 24827736
Hi,

Are you sure that your SSH server is up and ruunning?? Will you psot your:

netstat -anpt |grep ": 22"

output here ?

Also post  

iptables -L -n | grep dpt:22

output.

cheers,
K.
0
 

Author Comment

by:1030071002
ID: 24828162
asterisk-star@Asterisk:~$ netstat -anpt |grep ":22"
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -              
tcp6       0      0 :::22                   :::*                    LISTEN      -              
tcp6       0      0 ::1:22                  ::1:48172               ESTABLISHED -              
tcp6       0      0 ::1:48172               ::1:22                  ESTABLISHED 5511/ssh  

0
 

Author Comment

by:1030071002
ID: 24828170
asterisk-star@Asterisk:~$ iptables -L-n | dpt:22
iptables v1.4.1.1: can't initialize iptables table `filter': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
-bash: dpt:22: command not found
asterisk-star@Asterisk:~$


0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 80 total points
ID: 24828172
Where are you trying to ssh from?
What client/OS are you using?
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 78 total points
ID: 24828175
if you do

ssh 0

on the server what do you get?

do you have firewall in the path / network which could be resetting the session
0
 

Author Comment

by:1030071002
ID: 24828193
asterisk-star@Asterisk:~$ ssh 0
The authenticity of host '0 (0.0.0.0)' can't be established.
RSA key fingerprint is 00:e7:75:c7:13:f2:c2:69:7e:8c:a7:77:d4:5e:65:8f.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '0,0.0.0.0' (RSA) to the list of known hosts.
asterisk-star@0's password:

  System information as of Fri Jul 10 19:00:03 EDT 2009

  System load: 1.49              Memory usage: 41%   Processes:       141
  Usage of /:  63.1% of 7.23GB   Swap usage:   3%    Users logged in: 1

  Graph this data and manage this system at https://landscape.canonical.com/

Last login: Fri Jul 10 16:57:39 2009 from localhost


0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 186 total points
ID: 24828198
Hi,

please use sudo for iptables and netstat..
0
 

Author Comment

by:1030071002
ID: 24828201
using putty from windows 7
0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 186 total points
ID: 24828219
Can you do putty to your ubuntu ??
0
 

Author Comment

by:1030071002
ID: 24828283
asterisk-star@Asterisk:~$ sudo ssh 0
The authenticity of host '0 (0.0.0.0)' can't be established.
RSA key fingerprint is 00:e7:75:c7:13:f2:c2:69:7e:8c:a7:77:d4:5e:65:8f.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '0,0.0.0.0' (RSA) to the list of known hosts.
root@0's password:
Permission denied, please try again.
root@0's password:
Permission denied, please try again.
root@0's password:
Permission denied (publickey,password).
asterisk-star@Asterisk:~$ sudo ssh 0
root@0's password:
Permission denied, please try again.
root@0's password:


0
 

Author Comment

by:1030071002
ID: 24828314
no
0
 

Author Comment

by:1030071002
ID: 24828316
no puttyto ubuntu
0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 186 total points
ID: 24828381
Will you try this ??

$ ssh localhost

(without sudo. I've meant sudo for netstat and iptables commmands only)
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:1030071002
ID: 24828604
asterisk-star@Asterisk:~$ sudo ssh localhost
[sudo] password for asterisk-star:
The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is 00:e7:75:c7:13:f2:c2:69:7e:8c:a7:77:d4:5e:65:8f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
root@localhost's password:
Permission denied, please try again.
root@localhost's password:

Permission denied, please try again.
root@localhost's password:
Permission denied (publickey,password).
asterisk-star@Asterisk:~$


0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 186 total points
ID: 24828709
The problem here is:

when you call ssh with sudo the default user for ssh will be root user. The root user is not ssh enabled by default. So please try ssh without sudo!!!

Will you please post the outputs I've requested ?
0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 186 total points
ID: 24828754
If you want to enable root user to do ssh then edit your /etc/ssh/sshd_config. Locate the linr:

# PermitRootLogin yes

remove the leading #. restart yourssh server.

/etc/init.d/ssh restart

0
 

Author Comment

by:1030071002
ID: 24828956
already uncommented # PermitRootLogin yes
0
 

Author Comment

by:1030071002
ID: 24828973
connection still say refuse
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 80 total points
ID: 24828986
On the Linux server run sshd in debug mode, eg:

/usr/sbin/sshd -d

then try connecting and post the output from the debug messages here.
0
 

Author Comment

by:1030071002
ID: 24828998
asterisk-star@Asterisk:~$ sudo /usr/sbin/sshd -d
debug1: sshd version OpenSSH_5.1p1 Debian-5ubuntu1
debug1: read PEM private key done: type RSA
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: private host key: #0 type 1 RSA
debug1: read PEM private key done: type DSA
debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024
debug1: private host key: #1 type 2 DSA
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-d'
debug1: Bind to port 22 on 0.0.0.0.
Bind to port 22 on 0.0.0.0 failed: Address already in use.
debug1: Bind to port 22 on ::.
Bind to port 22 on :: failed: Address already in use.
Cannot bind any address.


0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 80 total points
ID: 24829013
Sorry, I forgot you need to shutdown ssh first before running in debug mode.

/etc/init.d/sshd stop
/usr/sbin/sshd -d


Ctrl-C to stop and then do

/etc/init.d/sshd start
0
 

Assisted Solution

by:pramodmrao
pramodmrao earned 26 total points
ID: 24829019
The default SSH port will be 22. In your case port 22 is already used some other service.

Check the service running in 22. Either change the port in that service or change in SSH configuration.
0
 
LVL 10

Assisted Solution

by:Andrew Doades
Andrew Doades earned 78 total points
ID: 24830007
it'll most likely be your hosts file...

/etc/hosts.allow
/etc/hosts.deny

in hosts.allow just add:

sshd: ALL

this will allow ssh access from everywhere.

Andrew
0
 
LVL 10

Assisted Solution

by:Andrew Doades
Andrew Doades earned 78 total points
ID: 24830016
You can also look here for more help with your hosts.allow and hosts.deny files...

http://ubuntuforums.org/showthread.php?t=248342

Andrew
0
 
LVL 7

Assisted Solution

by:darrickhartman
darrickhartman earned 52 total points
ID: 24831060
If the connection is refused, I still say it's the firewall.

What does :
              sudo iptables -L |grep dpt:22
show on the server?
0
 
LVL 10

Assisted Solution

by:Andrew Doades
Andrew Doades earned 78 total points
ID: 24832269
Its more likely to be the hosts file though.. I will admit I'm wrong if I am wrong, but I wouldn't rule this option out.. I've setup many different Linux and Unix servers and home PCs if my years and this has been a problem from time to time.

Andrew
0
 
LVL 7

Assisted Solution

by:darrickhartman
darrickhartman earned 52 total points
ID: 24832306
Andrew

I agree that it's a possibility, but unless he's changed something, the default on most linux distros is to allow ssh from anywhere.  The fact that the person asking the question can't copy and paste simple commands as requested above (by the KeremE) doesn't give me much hope that he'll ever solve the problem.
0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 186 total points
ID: 24832808
Hi,

I understand that your problem with SSH logon is not "connection refused" but it is "root login denied". So it has nothing to do with SSH not working since we already know that SSH is running. But the user called root can not login.

Did you restart your SSH server after allowing root login? If not you can use this command:

sudo /etc/init.d/ssh restart

and retry.

Cheers,
K.

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In today's information driven age, entrepreneurs have so many great tools and options at their disposal to help turn good ideas into a thriving business. With cloud-based online services, such as Amazon's Web Services (AWS) or Microsoft's Azure, bus…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now