LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 10: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, 10:11 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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, 10: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, 10: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, 10: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, 10: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, 10: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, 11:15 AM   #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, 11:19 AM   #9
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
maybe your isp changed your dynamic ip address. i use dyndns.com to track my ip.
 
Old 02-06-2014, 11:56 AM   #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, 12: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, 02: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, 04:40 PM   #13
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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, 08:05 PM   #14
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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, 09: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



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 01:48 PM
I want to start a ssh server. The_Messiah Linux - Networking 4 03-30-2005 01: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 05:18 PM
ssh to start at boot-up - AIX 4.3.2 ajoshay9 AIX 4 01-21-2004 08:44 PM
how to start up ssh deamon bennethos Linux - Newbie 2 10-21-2003 08:56 AM

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

All times are GMT -5. The time now is 02:05 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
Open Source Consulting | Domain Registration