LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-06-2014, 11:05 AM   #1
Ryanms3030
Member
 
Registered: Jan 2014
Distribution: Debian, Mint, CentOS, Ubuntu
Posts: 261

Rep: Reputation: Disabled
How to get SSH to start on boot?


I have tried using chkconfig sshd on for my CentOS server but every time I reboot I still have to manually start the sshd service. Seems to defeat the purpose of having a remote connection. Also, is there a reason that the default for this is to not have sshd start automatically? Is this a security best practice? I'm sure there is a reason it doesn't default to on but I can't figure it out
 
Old 02-06-2014, 11:11 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
chkconfig is the correct way but one way to hack it would be to put
Code:
service sshd start
at the end of your /etc/rc.local.
 
Old 02-06-2014, 11:13 AM   #3
Isaac Velando
LQ Newbie
 
Registered: Feb 2014
Location: Texas
Distribution: Arch, Ubuntu Server, CentOS
Posts: 29

Rep: Reputation: 21
I'm interested in the output of
Code:
chkconfig --list | grep sshd
runlevel
as I'm wondering if either your chkconfig syntax was off or if you set it to a different runlevel than you're running on.
 
Old 02-06-2014, 11:25 AM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Ryanms, something is wrong with your server and/or ssh daemon. A good starting point would be the output from Isaac's commands.
 
Old 02-06-2014, 11:25 AM   #5
Ryanms3030
Member
 
Registered: Jan 2014
Distribution: Debian, Mint, CentOS, Ubuntu
Posts: 261

Original Poster
Rep: Reputation: Disabled
i get this output on :

Code:
sshd           	0:off	1:off	2:on	3:on	4:on	5:on	6:off
 
Old 02-06-2014, 11:28 AM   #6
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Also post the output from 'runlevel' command. (Hopefully / presumably you're in runlevel 3.)

Then check /var/log/secure and /var/log/messages for any errors specifically related to sshd - around the time of your most recent reboot.
 
1 members found this post helpful.
Old 02-06-2014, 11:35 AM   #7
Isaac Velando
LQ Newbie
 
Registered: Feb 2014
Location: Texas
Distribution: Arch, Ubuntu Server, CentOS
Posts: 29

Rep: Reputation: 21
Right, if you are on runlevel 3 then follow anomie's advice and see if there are errors with your sshd in the logs. Additionally, you can run
Code:
sshd -t
which reports any configuration errors in /etc/ssh/sshd_config in case you've recently made adjustments around the time this problem began.
 
Old 02-06-2014, 12:15 PM   #8
Ryanms3030
Member
 
Registered: Jan 2014
Distribution: Debian, Mint, CentOS, Ubuntu
Posts: 261

Original Poster
Rep: Reputation: Disabled
I'm at work now so I'll have to get the other info later. I used to be able to ssh from outside my house using the server's public IP but now when I try that it keeps timing out. So that is something else I will need to figure out
 
Old 02-06-2014, 12:19 PM   #9
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
maybe your isp changed your dynamic ip address. i use dyndns.com to track my ip.
 
Old 02-06-2014, 12:56 PM   #10
sashi_hc
LQ Newbie
 
Registered: Aug 2012
Posts: 6
Blog Entries: 1

Rep: Reputation: Disabled
Try systemctl

#systemctl enable sshd.service

Try that. Your sysconfig should automatically redirect you, but try that. Later linux versions use this.
The first time, also say
#systemctl start sshd.service
 
1 members found this post helpful.
Old 02-06-2014, 01:38 PM   #11
Ryanms3030
Member
 
Registered: Jan 2014
Distribution: Debian, Mint, CentOS, Ubuntu
Posts: 261

Original Poster
Rep: Reputation: Disabled
Thanks for all the advice. I checked my public ip yesterday and it was still the same as I had been using. I am going to sign up for a free account on afraid.org
 
Old 02-06-2014, 03:57 PM   #12
Isaac Velando
LQ Newbie
 
Registered: Feb 2014
Location: Texas
Distribution: Arch, Ubuntu Server, CentOS
Posts: 29

Rep: Reputation: 21
If the IP hasn't changed, might you have changed the listening port in sshd_config without also changing your router's port forwarding to reflect the new port? I think once you check /var/log/secure and /var/log/messages for sshd entries you'll know more; if there's something wrong with the configuration then that's going to be responsible for an inability to ssh in from outside. That being said it can't hurt to manage a potentially changing IP address, but I recommend making sure you pin down the root of the problem before moving on.
 
Old 02-06-2014, 05:40 PM   #13
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
Quote:
Originally Posted by Ryanms3030 View Post
I have tried using chkconfig sshd on for my CentOS server but every time I reboot I still have to manually start the sshd service. Seems to defeat the purpose of having a remote connection. Also, is there a reason that the default for this is to not have sshd start automatically? Is this a security best practice? I'm sure there is a reason it doesn't default to on but I can't figure it out
as root you can also run setup and perform the check via the dialog box that will popup. i think there might be something bugged with chkconfig in CentOS 6.x atm. when i run
Code:
[root@centos ~]# chkconfig sshd
[root@centos ~]#
there is zero output, but when I look at my services via setup, sshd is configured to[*], meaning start at boot and mine does start at boot.
 
Old 02-06-2014, 09:05 PM   #14
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
Quote:
Originally Posted by sashi_hc View Post
#systemctl enable sshd.service

Try that. Your sysconfig should automatically redirect you, but try that. Later linux versions use this.
The first time, also say
#systemctl start sshd.service
i think i also read somewhere that systemctl is taking over.
 
Old 02-06-2014, 10:18 PM   #15
Ryanms3030
Member
 
Registered: Jan 2014
Distribution: Debian, Mint, CentOS, Ubuntu
Posts: 261

Original Poster
Rep: Reputation: Disabled
So, I am running runlevel 5. I'm a noob and still like the gui as a safety net but most of the time I'm ssh in through the terminal. If the runlevel is part of the problem I can change it to boot in 3.

systemctl start sshd.service gives me:


bash: systemctl: command not found
 
  


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
Using SSH to start a program anupamsr Linux - General 3 08-02-2006 02:48 PM
I want to start a ssh server. The_Messiah Linux - Networking 4 03-30-2005 02:56 AM
I turned off SSH, but I cant get it back! How do you start SSH on boot? nmoog Slackware 2 02-08-2004 06:18 PM
ssh to start at boot-up - AIX 4.3.2 ajoshay9 AIX 4 01-21-2004 09:44 PM
how to start up ssh deamon bennethos Linux - Newbie 2 10-21-2003 09:56 AM


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

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