Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 4015  / 2 Years ago, tue, march 29, 2022, 2:18:02

I've a VPS with Ubuntu 18.04Lts on Google Cloud.


On every reboot, I've to start the ssh daemon service either by service ssh(d) start or systemctl start ssh(d) (both ssh and sshd work the similar way and start the needed service.


But its very difficult and cumbersome to start the server on serial ports and then start the ssh service on the server. I've tried the following ways to configure the service to start behind it. I've found all the ways in diff articles found thru google or on Stack answers (I don't know the reasons/logics behind them). I did them one by one, mostly without first undoing the prev one.



  1. Tried installing and reinstalling the openssh-server.

  2. Ran this command: sudo systemctl enable sshd.service

  3. Ran this command: systemctl enable sshd

  4. Ran this command: sudo update-rc.d sshd defaults

  5. Ran this command: systemctl enable ssh.socket

  6. Checked that symbolic link of /etc/rc*.d/S**ssh are there

  7. Commenting out the specific ListenAddress directive and adding ListenAddress 0.0.0.0 to let sshd listen on any address in the file : /etc/ssh/sshd_config.

  8. Edited this line # Required-Start: $remote_fs $syslog to this line # Required-Start: $remote_fs $syslog $network in the file /etc/init.d./ssh (to stop sshd from starting before the network is ready).

  9. Added this line: sshd & to the (end of) file /etc/init.d/rc.local.

  10. Edited this file: /etc/rc.local and added this line: /etc/init.d/ssh start

  11. Edited the /etc/ssh/sshd_config file and in it, change Port to 2222. Also set the PasswordAuthentication to yes.

  12. Added/tried these lines in root's crontab file: @reboot mkdir -p -m0755 /var/run/sshd && systemctl restart ssh.service. Didn't work, then tried this @ systemctl restart ssh.service. then commented out this also, And tried this: @reboot service ssh start. But again, commented out this one and tried this last one: @reboot sleep 15 && /bin/systemctl restart sshd.


Even after trying these 15 solutions, the ssh service still doesn't start upon reboot.
Kindly do help.


More From » server

 Answers
0

First, this proved to be one of few problems of my carrier, for which I couldn't find any solution on Google/Stack Exchange etc!!


In the end, after spending more than 2 to 3 'FULL' days on this problem and reading tens of web pages, I finally happen to solve it by accident.


When the instance was showing its display thru serial ports, I happen no note one error which showed that it was trying to mount a hard disk, which was no longer available. And on further looking, I found that because of this 'unfindable' disk, the nginx service wasn't starting (I don't know the reasons behind this). And because of this, later I found, the ssh daemon service wasn't being started (I don't know why ssh(d) service was able to start manually when I commanded it thus?!!


So, solution is, edited the file /etc/fstab and removed the auto-mounting line from it. It caused Nginx to load properly, which caused 'sshd' to start/load properly!!


And to think!!, no solution on tens of forums, happen to mention this.


[#1554] Thursday, March 31, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
arsleyeuth

Total Points: 72
Total Questions: 121
Total Answers: 112

Location: North Korea
Member since Mon, Oct 31, 2022
2 Years ago
;