LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-12-2007, 10:39 AM   #1
kempy1000
LQ Newbie
 
Registered: Feb 2007
Distribution: Mandriva
Posts: 12

Rep: Reputation: 0
Ssh server problems


Im trying to use ssh
Ive set up my ssh server

I can login locally (chris@localhost)

But if i use putty from any machine the connection times out and if i do chris@192.168.62.54 in cygwin i get timed out too

All the other machines i tested it from are in the same LAN but if thats the problem i need to find a way around that because im going to use startx from cygwin to get a interface.

Could anyone suggest a solution please?
 
Old 02-12-2007, 11:11 AM   #2
guruyaya
LQ Newbie
 
Registered: Feb 2007
Posts: 8

Rep: Reputation: 0
Using tcpdump could help you understand if there is a problem on your system, or a problem on your network. Just write down "tcpdump src (machine address)" to see if you`re getting any packets. Now if you do, there's probably a firewall problem. Just pulish iptables -L and we'll probably be able to help you. If it's not, then it seems more like a network problem. G'luck!
 
Old 02-12-2007, 11:13 AM   #3
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Welcome to LQ!

This sounds a bit like a firewall problem. Post the output of iptables -L -n or your firewall script and we can have a look. Also have a look in /etc/hosts.allow and /etc/hosts.deny as they could also be causing something like this.

Finally, make sure that sshd is listening on port 22. You should see it if you run netstat -pantu | grep sshd as root in a console.
 
Old 02-12-2007, 11:48 AM   #4
kempy1000
LQ Newbie
 
Registered: Feb 2007
Distribution: Mandriva
Posts: 12

Original Poster
Rep: Reputation: 0
I am a bit of a noob so i have no idea what a firewall script is
I did the iptables and my output is:

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Thanks for the help
 
Old 02-12-2007, 01:05 PM   #5
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
OK, one down, two to go. That iptables output means that you don't have a firewall in place. You'll want to learn how to address that in the near future, but for now it means that it isn't part of the problem.

Now if you could check on the hosts.allow/deny files and the netstat output.
 
Old 02-13-2007, 08:42 AM   #6
kempy1000
LQ Newbie
 
Registered: Feb 2007
Distribution: Mandriva
Posts: 12

Original Poster
Rep: Reputation: 0
Thank you very much it was the hosts.allow/.deny files i had

ALL:EXCEPT 127.0.0.1ENY

Now i have sorted that and can connect i have another issue when i connect it works fine but sometimes say every 2hour or so the hosts.deny file updates and the line

ALL:EXCEPT 127.0.0.1ENY

appears from no where

The hosts.allow file is unaltered what could be causing this?
 
Old 02-13-2007, 08:53 AM   #7
M0E-lnx
LQ Newbie
 
Registered: Feb 2007
Distribution: Vector Linux
Posts: 8

Rep: Reputation: 0
Are you sure your ssh daemon is running?
Code:
pidof sshd
I ssh my box @ home every day from a windows box @ work... ... just make sure the daemon is running.
When the daemon is not running, most of the time you get a "time out" error
when the firewall is kicking you out, you get a "connection refused" error

I'm not sure what distro you're using, but on My vector Linux, this is how I start it
Code:
service sshd start
or
Code:
/etc/rc.d/init.d/sshd start
I think you should try that before you start messing with iptables...

Last edited by M0E-lnx; 02-13-2007 at 08:58 AM.
 
Old 02-13-2007, 09:40 AM   #8
tsunami_imcool
Member
 
Registered: Mar 2005
Distribution: Debian
Posts: 80

Rep: Reputation: 15
Sometimes when I can't login to my machine with SSH when I have been able to before, I will usually just go to the machine itself, login, and then delete everything out of my ~/.ssh file, or its something like that, i havent checked for while, but its got the key id's in there. Not that this is a good way, it just seems to work when I need it too .
 
Old 02-13-2007, 11:42 AM   #9
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Originally Posted by kempy1000
Thank you very much it was the hosts.allow/.deny files i had

ALL:EXCEPT 127.0.0.1ENY

Now i have sorted that and can connect i have another issue when i connect it works fine but sometimes say every 2hour or so the hosts.deny file updates and the line

ALL:EXCEPT 127.0.0.1ENY

appears from no where

The hosts.allow file is unaltered what could be causing this?
You never say what distro you're using, but it looks as if it is trying to forcibly keep the hosts.deny file intact as a means of securing the box. That's OK, because the hosts.allow file gives you a way to let stuff in. The basic idea is that hosts.deny keeps everything out EXCEPT for the rules in hosts.allow, so if you add a rule to hosts.allow that lets in an SSH connection, you should be good to go.

There is a nice example here on how to do this, but basically you need to add a line to hosts.allow like this:

sshd : ALL : ALLOW

That should allow all ssh connections to come through. Now, if you are going to be connecting from a limited number of IP addresses, rather than allowing ALL IP addresses, you could restrict it:

sshd : XXX.XXX.XXX.XXX : ALLOW


and just replace the XXX bit with the IP address you want to allow in. Allowing ALL in is certainly easier, but it does expose you to a greater security risk. Of course if you will always be accessing SSH from machines you own, you could do away with username/password authentication and go with key based authentication. There is a nice tutorial on how to do that here.
 
Old 02-13-2007, 04:13 PM   #10
kempy1000
LQ Newbie
 
Registered: Feb 2007
Distribution: Mandriva
Posts: 12

Original Poster
Rep: Reputation: 0
Thank you
Problem Sorted I did what you said about the hosts.* files
 
Old 02-14-2007, 09:49 AM   #11
kempy1000
LQ Newbie
 
Registered: Feb 2007
Distribution: Mandriva
Posts: 12

Original Poster
Rep: Reputation: 0
Oh somaybe problem not sorted
I turned my server on this morning tried to ssh back into it and connection refused?

Hosts.deny:
ALL:EXCEPT 127.0.0.1ENY

Hosts.allow
sshd:ALL EXCEPT 192.168.1.2:ALLOW
 
Old 02-14-2007, 10:35 AM   #12
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Is 192.168.1.2 your router? By including that IP in your hosts.allow file after an EXCEPT, you're preventing any connections from there, so if that is a critical part of your network, it might be the problem.
 
Old 02-14-2007, 10:53 AM   #13
kempy1000
LQ Newbie
 
Registered: Feb 2007
Distribution: Mandriva
Posts: 12

Original Poster
Rep: Reputation: 0
192.168.1.2
Thats only there because i forgot to remove it when i looked at the examples it is nothing on my network. (bit of a stupid mistake its gone now)
 
Old 02-14-2007, 11:01 AM   #14
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
OK, If it is still not working I would do two things:

1) check that sshd is actually running
2) Look in your log files (/var/log/syslog and /var/log/messges) and the dmesg output and see if sshd is complaining or leaving any clues.
3) (OK, I lied about 2 thiings) Check your router and make sure that port 22 is being forwarded to the correct IP address. If you use DHCP to get an IP address, the server's IP may have changed and caused this problem.
 
Old 02-14-2007, 11:13 AM   #15
kempy1000
LQ Newbie
 
Registered: Feb 2007
Distribution: Mandriva
Posts: 12

Original Poster
Rep: Reputation: 0
I did
service sshd status
and got
sshd dead but subsys locked
so i did
service sshd start
and now it works
thanks again
 
  


Reply



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
Problems setting Permissions for my SSH server nativeone Fedora 1 05-05-2006 06:07 PM
Passwordless SSH with SSH commercial server and open ssh cereal83 Linux - General 7 04-18-2006 12:34 PM
pty problems with ssh server Elric of Grans Linux - Software 2 12-11-2005 06:54 PM
problems with openssh server (ssh) shodekiagari Linux - Networking 10 10-16-2005 05:37 AM
Problems accessing server using ssh client. rmc Linux - Networking 1 12-12-2002 02:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:57 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