LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-31-2008, 09:42 PM   #1
The Traveler
LQ Newbie
 
Registered: Oct 2002
Posts: 6

Rep: Reputation: 0
Automatically starting sshd at boot


Hi all,

I have ssh server installed on a pc running Fedora 8.

When I log in as root or as another user and stay logged in I can connect to this pc from another machine at work or another machine at home. However when I log out and get the graphical login screen then SSH is no longer available to me: I get the error message 'NETWORK ERROR: Connection timed out.' I'd like to be able to connect via ssh without leaving a user account logged in all the time.

Here's what I've done so far to try to correct the issue:
1. used the GUI to select ssh to be automatically started (in runlevels 3 4 and 5, which are the only ones available in that gui)
2. edited /etc/rc.local and added the line '/etc/init.d/sshd start'
3. ran ntsysv from the command line and made sure that sshd was checked

I tried restarting ssh and then restarting the pc after making these changes. None of these things worked.

Any suggestions?

Thank you in advance,

The Traveler
 
Old 05-31-2008, 10:32 PM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
Does your machine have a global static IP or a 'private' IP? If it has a private IP then getting to it is tricky; you need to know the IP on the WAN side of your modem and you need to set up the modem to forward all ssh packets to that one computer (which of course means that other computers can't even access internet machines via ssh).
 
Old 05-31-2008, 11:11 PM   #3
The Traveler
LQ Newbie
 
Registered: Oct 2002
Posts: 6

Original Poster
Rep: Reputation: 0
Hi, pinniped.

I have a small 4-port switch with 2 machines connected to it. The switch runs to a dedicated firewall machine running Smoothwall which then connects to my modem. I've given both internal PCs their own static ip. With or without an internet connection (I've turned my modem off to try it) my windows pc can connect to my linux pc (using the client Putty) if I have logged in on the linux pc with any account, root or otherwise. However if my linux pc is at the gui login then I can't connect. It's not a huge deal to leave a normal user account logged in because these pcs are in my home (and the little data I have is worth much much less than the pcs it resides on) but it is a little aggravating to have to do so.

Also, where can I change the necessary settings or flags to get a normal text-mode login prompt? I've looked in the menu System > Administration > XXX and can't find that option anywhere. I did find a reference online that said to edit /etc/sysconfig/init and change the line GRAPHICAL = yes to GRAPHICAL = no -- this didn't work for me. I don't think it's necessary to have the graphical server running if all I want to do (right now) is set the linux box up so that I can ssh in to it and roam around.
 
Old 06-01-2008, 12:05 AM   #4
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
There are a few situations I can think of that would cause your ssh problems:
1. sshd is run via 'xinetd' (or inetd, but RH has always prefered xinetd)
2. sshd is somehow run when you log into a text console but not run otherwise

One thing to look into is your runtime scripts. RH is slightly different to what Debian does (and I can only tell you what Debian does, which is more typical of UNIX). Anyway, there is a directory somewhere in /etc which contains service scripts - these scripts are run to start or stop a service (such as X or sshd). Elsewhere in /etc are directories containing symbolic links to those scripts; on Debian they are rcS.d, rc0.d .. rc6.d where the 'S' means 'startup' - those are scripts which absolutely have to be run to put the system in a working state. The '0' is for scripts that are run to shut down the system, and the '6' is for a reboot. Everything in 1..5 can be set by the sysadmin to do whatever they please, but '1' is normally for "maintenance mode" (only enough services are run to allow the admin to tinker with the system, plus only the admin is allowed to log in).

So, what to do with these directories? If you look in them you'll see symbolic links like:
S10sysklogd -> ../init.d/sysklogd
K40dhcp3-server -> ../init.d/dhcp3-server

The 'S' at the start of the link's name means invoke the script with the argument 'start' while the 'K' means invoke with the argument 'stop' (kill). When the machine starts up, everything in rcS.d is run, then depending on the selected runlevel 'N', the scripts in rcN.d are invoked. RH (and many Linux distros but not Debian) often sets things so that runlevel 2 will give you a plain text console while runlevel 3 gives you X.

Have a look at the links in 'rc2.d' and in 'rc3.d' - can you see which services are guaranteed to be running or guaranteed to be shut down when you switch to that runlevel?

How do you select a runlevel at boot? Just edit the 'grub' menu.lst (or lilo.conf if you use lilo) and make sure runlevel=2 is added to the kernel boot parameters (actually anything from 1..5 - '0' if you're silly and want the computer to shut down on boot, and '6' if you want infinite reboots). Now if X happens to be started in runlevel 2, simply go into that directory and rename the link - for example:
S99kdm -> ../init.d/kdm
So I do:
mv S99kdm K01kdm
(It's probably safe to make it K99kdm, but using '100-XX' when you change from SXX to KYY or vice-versa is usual because it helps preserve the correct order in starting/stopping things.)

Now when runlevel 2 starts, there will be no more KDM.

In a similar fashion, see if there is a 'KXXssh' or if there is any mention at all of ssh:
ls *ssh*

Just add/modify the link as necessary:
ln -s ../init.d/ssh SXXssh
Hmm.. you have to choose 'XX' carefully because obviously the network has to be brought up before SSH can run - unless you plan to only run on the loopback interface.

Once you have set up just the way you want:
telinit 2 (switch to runlevel 2)
but if you were already in runlevel2 and 'telinit' tries to be intellgent and ignore you, do:
telinit 1
and after the switch
telinit 2


Now for a few more tricks:
Have a look at the ssh script (in /etc/init.d on Debian - I can't remember where RH puts it)
There are a number of possibilities here - the script can refuse to run sshd directly because of some condition that says "sshd is only to be run via xinetd", or sshd refuses to run because of a condition saying "the user doesn't ever want to run sshd". How that is accomplished depends on the whims of whoever writes the scripts - on Debian for example, to prevent sshd running, a file /etc/ssh/sshd_not_to_be_run is created.

Have fun playing around, ask more questions when you get stuck again.
 
Old 06-01-2008, 06:18 AM   #5
The Traveler
LQ Newbie
 
Registered: Oct 2002
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks, pinniped.

That was pretty informative. I'm still pretty new to Linux and it amazes me how much you can change about it - it' a bit intimidating at times, actually!

I looked through /etc/init.d and found the script for sshd. I checked /etc/rc3.d through /etc/rc5.d and made sure there was a Sxxxxx link to sshd. I didn't find anything like SxxxxX11 (I think the X server is called X11, right?). I did find a link called S00 fedora-live and a script in /etc/init.d called fedora-live. Does this make a difference? I did install this via a live-cd instead of a regular DVD distribution.

Also, during bootup I paid attention to everything that came up on screen - or at least I tried to; it's a bit fast. I read a line that said INIT was starting in runlevel 5. I read 'Starting sshd [OK]' so that tells me that sshd started without problems, right?

Also at reboot I eventually ended up at a text login prompt but 2 seconds later the GUI started automatically without any input from me. Is this normal? I edited the file /etc/sysconfig/init to read 'GRAPHICAL = no' to disable graphical boot.

Finally during bootup I noticed one line that failed: NFS Statd [FAILED]. What is this item?

Sorry for the deluge of questions and thanks for your patience!

The Traveler

Last edited by The Traveler; 06-01-2008 at 06:24 AM.
 
Old 06-04-2008, 08:21 AM   #6
The Traveler
LQ Newbie
 
Registered: Oct 2002
Posts: 6

Original Poster
Rep: Reputation: 0
Bump.

I still haven't figured out how to keep Fedora 8 from booting to graphical login by default. I'd prefer to boot to a text prompt and not have the X11 server start at all. How can I do this?

During boot the line 'Starting sshd [OK]' scrolls up the screen (among all the others) so ssh is obviously starting. I suspect that whatever script or option causes Fedora 8 to launch into graphical mode may be stopping the ssh daemon; if I could just get it to stay text mode I'd find out.

Any suggestions? Thanks!
 
Old 06-04-2008, 02:16 PM   #7
aditya immaneni
LQ Newbie
 
Registered: Jun 2008
Posts: 2

Rep: Reputation: 0
Hi,

Remove the /etc/init.d/sshd start from /etc/rc.local
Login as root and run the command chkconfig --level 345 ssh on
This will setup ssh to start when you boot in command line mode or graphical user mode.

Thanks.

Quote:
Originally Posted by The Traveler View Post
Hi all,

I have ssh server installed on a pc running Fedora 8.

When I log in as root or as another user and stay logged in I can connect to this pc from another machine at work or another machine at home. However when I log out and get the graphical login screen then SSH is no longer available to me: I get the error message 'NETWORK ERROR: Connection timed out.' I'd like to be able to connect via ssh without leaving a user account logged in all the time.

Here's what I've done so far to try to correct the issue:
1. used the GUI to select ssh to be automatically started (in runlevels 3 4 and 5, which are the only ones available in that gui)
2. edited /etc/rc.local and added the line '/etc/init.d/sshd start'
3. ran ntsysv from the command line and made sure that sshd was checked

I tried restarting ssh and then restarting the pc after making these changes. None of these things worked.

Any suggestions?

Thank you in advance,

The Traveler
 
Old 06-04-2008, 06:21 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,395

Rep: Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395
Use this to check the init runlevel

cat /etc/inittab

this is the line you need

# The default runlevel is defined here
id:3:initdefault:

Yours is prob set to 5 instead of 3. You can change/edit this file from root ( su - ) and reboot. Note that I highly doubt this has anything to do with the ssh daemon 'stopping'.
One way you can check is to simply open up an xterm on the server and do

ps -ef|grep sshd

to see if sshd is running, without messing with inittab.


NFS = Network File Sharing, a UNIX-to-UNIX disk share service. Can also be used by MS if you've got the correct SW installed. (Not the same thing as Samba).
http://www.onlamp.com/pub/a/bsd/2002...y_Daemons.html
 
Old 06-08-2008, 01:40 AM   #9
The Traveler
LQ Newbie
 
Registered: Oct 2002
Posts: 6

Original Poster
Rep: Reputation: 0
Hi all,

I've resolved the issue in a way. Since I just got a new computer a month or so ago I decided to wipe the hard drive on the old one, which was a dual boot setup with WinXP and Linux, and just run Linux on it. I decided to take the time to download all the images for CDs instead of using the Live CD I already have and which I used to install Fedora 8 before. I did this because I had a weird theory that my problems stemmed from the live cd installation - crazy idea but I'm a relative newb so I'm entitled he he.

Anyway, after installing from the CDs I started sshd and set it to run in runlevels 2 through 5 (using the gui on the gnome desktop), logged out and got the gui login screen, then connected to it from my Windows pc. Success!

So, since I'm a sucker for punishment I wiped the hard drive, installed from the live cd, started sshd and set it to run in runlevels 3 through 5 (using gnome's gui - only 3 through 5 are offered in this gui instead of 2 through 5 ???), connected successfully from Windows pc, logged out, could NOT connect from Windows pc.

Then wiped hard drive (I've got lots of free time) and reinstalled from the CDs. Success again.

So, problem solved on my end. I'm just curious about a few things. Why DOESN'T setting the runlevels on the Live CD install work and the Normal CD DOES work? Why the different Services gui (on gnome desktop both times) between Live CD install and Normal Cd install? Why the different login gui between them since they're both Fedora 8? Why am I so punchy at 2:30 am after 2 liters of CocaCola and a bag of cheetos (I'm a wobbly, not a skinny)? Keep in mind these questions aren't complaints, just curiosity.
 
  


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
Starting sshd: /etc/init.d/sshd: line 113: /usr/sbin/sshd: Permission denied sumanc Linux - Server 5 03-28-2008 04:59 AM
kde not starting automatically at boot google01103 SUSE / openSUSE 2 12-12-2006 07:19 AM
FC4-Starting sshd: Privilege separation user sshd does not exist FAILED kiranherekar Fedora 5 12-29-2005 02:22 PM
sshd not starting up on boot after upgrade babis Linux - Software 1 03-18-2004 07:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:10 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration