← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1322640] Re: cloud-init fails to restart ssh server

 

So the problem here was that you were relying on user-scripts (which are
executed via upstart job 'cloud-final.conf') to run before the ssh
upstart job.

Looking at these 2 jobs:
 precise:
  - ssh.conf: 
    start on filesystem or runlevel [2345]
  - cloud-final.conf:
    start on (stopped rc RUNLEVEL=[2345] and stopped cloud-config)

trusty:
  - ssh.conf:
    start on runlevel [2345]
  - cloud-final.conf:
    start on (stopped rc RUNLEVEL=[2345] and stopped cloud-config)

So I think that what is happening is just that the 'sed' is occurring after ssh has started on trusty, but before on precise.
I'm not actually able to explain that easily though.  Some other event must have been blocking the ssh job on precise, forcing it to start later.

I'm fairly sure  that in both cases you are guaranteed for a 'boothook' to run before ssh starts.
boothooks are executed by cloud-init.conf (or cloud-init-local.conf)
cloud-init.conf:
  - start on mounted MOUNTPOINT=/ and stopped cloud-init-nonet

that will block either 'filesystem' or 'runlevel' from occuring, so ssh
wont start until its done.

So.... now in short, the answer is for you to just do:

#cloud-boothook
#!/bin/sh
sed -i "s/^Port 22$/Port 622/" /etc/ssh/ssd_config



** Changed in: cloud-init
   Importance: Undecided => Low

** Changed in: cloud-init
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1322640

Title:
  cloud-init fails to restart ssh server

Status in Init scripts for use on cloud images:
  Invalid

Bug description:
  In the past I've been able to start ssh on a non-standard port with
  the user script below.  However since upgrading from 12.04, I must
  manually restart the ssh server on the new instance after it boots.

  
  Content-Type: multipart/mixed; boundary="===============2128276640157684233=="
  MIME-Version: 1.0

  --===============2128276640157684233==
  Content-Type: text/x-shellscript; charset="us-ascii"
  MIME-Version: 1.0
  Content-Transfer-Encoding: 7bit
  Content-Disposition: attachment; filename="user-script.txt"

  #!/bin/sh

  # change ssh port 22 to non-standard port and restart sshd
  sed -i "s/^Port 22$/Port 622/" /etc/ssh/sshd_config
  /etc/init.d/ssh restart

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1322640/+subscriptions


References