# SSH 'Connection Refused' [solved]

## Lousie_Louie

Every time I try to ssh into my box (inside and outside my local network) i get a 'connection refused' error.

The obvious thing would to be sure that my firewall is allowing the right ports, but I found out I did not have iptables, and I need to emerge that, So I did. 

The I found out that I need to change something in my kernal to get iptables working.  All I really want to do is turn my firewall off, but I'm not sure if I have one.  I didn't know networking would work without iptables. 

Do I need to recompile my kernal to get this working? or is there a simpler way?

(I am look at directions here: http://gentoo-wiki.com/HOWTO_Iptables_for_newbies )Last edited by Lousie_Louie on Thu Jun 09, 2005 2:54 am; edited 1 time in total

----------

## raf

If you want your firewall off then why did you emerge iptables? Just get rid of it! This way you will not have a firewall.

I know this sounds simple, but is your sshd service running? I've had that happen to me a couple of times where it would just say connection refused and it turned out my sshd service was down. Try:

```
/etc/init.d/sshd restart
```

----------

## gnuageux

/etc/init./sshd status  will also tell you if its running.

----------

## rex123

 *Lousie_Louie wrote:*   

> Every time I try to ssh into my box (inside and outside my local network) i get a 'connection refused' error.
> 
> The obvious thing would to be sure that my firewall is allowing the right ports, but I found out I did not have iptables, and I need to emerge that, So I did. 
> 
> [...]

 

What you did was to install a firewall in order to turn it off. This is probably a useful exercise, because iptables is a fun application, but it's not going to help you fix your sshd problem. You then suggest modifying your kernel. Again, this is fun if you have time on your hands, but it is extremely unlikely to fix your sshd problem.

Some other things to try (apart from /etc/init.d/sshd status):

ssh localhost (from the machine itself). This will bypass all networking (and firewalls), so you will see if sshd is responding.

netstat -lntp (as root). This shows you what is listening on what port. Look for something listening on port 22. If it's not there, it isn't running.

----------

## Lousie_Louie

Ok it doesn't look like it is running.

```

root@axiom axiom # sshd

sshd re-exec requires execution with an absolute path

root@axiom axiom #  find / -name sshd

/etc/pam.d/sshd

/etc/init.d/sshd

root@axiom axiom # /etc/init.d/sshd restart

root@axiom axiom # ssh localhost

ssh: connect to host localhost port 22: Connection refused

root@axiom axiom #

```

Hope one of you helpful people can make sense of this.

----------

## gnuageux

I think that by default ssh is set to refuse localhost connections  :Smile: 

$nmap localhost  

See if its an open port, Ill be it is. Im sure somone around here knows how to allow ssh connections from localhost, but I dont off the top of my head and im @ work  :Sad: 

----------

## Lousie_Louie

I have no ports open.  Got the same result from another box on my local network.  It would appear that I have a nice firewall up, but I havn't got on installed, nor do I have the iptables module on my kernal.

```

root@axiom axiom # nmap localhost

Starting nmap 3.81 ( http://www.insecure.org/nmap/ ) at 2005-06-08 21:03 EDT

All 1663 scanned ports on localhost (127.0.0.1) are: closed

Nmap finished: 1 IP address (1 host up) scanned in 0.292 seconds

root@axiom axiom #     
```

I thought I understood these things when I was on debian, but now I am confused.

<clarify> All I want to do is to be able to ssh into my box. </clarify>

----------

## gnuageux

Huh, whats /etc/init.d/sshd status  return?

----------

## Lousie_Louie

nothing.  You'd think it'd throw some sort of error if it failed.

```

root@axiom axiom # /etc/init.d/sshd

root@axiom axiom # /etc/init.d/sshd status

root@axiom axiom #

```

it does throw an error if I don't give the full path

```

root@axiom axiom # sshd

sshd re-exec requires execution with an absolute path

root@axiom axiom #

```

somthing is there...

----------

## Lousie_Louie

OK this page

http://gentoo-wiki.com/HOWTO_setup_a_home-server#Configuring_ssh

helped a lot.  I emerged openssh and it works.  Though I had emerged sshd before.  Anyway thanks, you guys are awsome.

----------

