SSH Host Keys regenerated at every reboot

125 views
Skip to first unread message

Giovanni Toraldo

unread,
Feb 9, 2016, 11:06:15 AM2/9/16
to gce-discussion
Hi,


it looks like that GCE instances with Ubuntu 14.04 template get host keys regenerated at every reboot:


ubuntu@pimo-drupalmysqldeploytestit-19:/etc/ssh$ ll
total 304
drwxr-xr-x 2 root root 4096 Feb 9 15:55 ./
drwxr-xr-x 105 root root 4096 Feb 9 15:56 ../
-rw-r--r-- 1 root root 242091 Jan 13 16:38 moduli
-rw-r--r-- 1 root root 139 Feb 9 15:44 ssh_config
-rw-r--r-- 1 root root 474 Feb 9 15:44 sshd_config
-rw------- 1 root root 672 Feb 9 15:54 ssh_host_dsa_key
-rw-r--r-- 1 root root 652 Feb 9 15:54 ssh_host_dsa_key.pub
-rw------- 1 root root 227 Feb 9 15:54 ssh_host_ecdsa_key
-rw-r--r-- 1 root root 224 Feb 9 15:54 ssh_host_ecdsa_key.pub
-rw------- 1 root root 476 Feb 9 15:54 ssh_host_ed25519_key
-rw-r--r-- 1 root root 144 Feb 9 15:54 ssh_host_ed25519_key.pub
-rw------- 1 root root 1001 Feb 9 15:55 ssh_host_key
-rw-r--r-- 1 root root 666 Feb 9 15:55 ssh_host_key.pub
-rw------- 1 root root 1675 Feb 9 15:54 ssh_host_rsa_key
-rw-r--r-- 1 root root 444 Feb 9 15:54 ssh_host_rsa_key.pub
-rw-r--r-- 1 root root 338 Jan 14 17:09 ssh_import_id
-rw-r--r-- 1 root root 1595 Feb 9 15:44 sysadmin_authorized_keys

ubuntu@pimo-drupalmysqldeploytestit-19:/etc/ssh$ uptime
15:58:28 up 3 min, 2 users, load average: 1.72, 0.77, 0.29


In fact in the /var/log/cloud-init.log I've found:

2016-02-09 15:54:57,496 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_key
2016-02-09 15:54:57,496 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_ecdsa_key
2016-02-09 15:54:57,496 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_ecdsa_key.pub
2016-02-09 15:54:57,496 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_ed25519_key
2016-02-09 15:54:57,496 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_dsa_key.pub
2016-02-09 15:54:57,496 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_rsa_key
2016-02-09 15:54:57,496 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_dsa_key
2016-02-09 15:54:57,496 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_ed25519_key.pub
2016-02-09 15:54:57,496 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_rsa_key.pub
2016-02-09 15:54:57,496 - util.py[DEBUG]: Attempting to remove /etc/ssh/ssh_host_key.pub
2016-02-09 15:54:57,497 - util.py[DEBUG]: Running command ['ssh-keygen', '-t', 'rsa', '-N', '', '-f', '/etc/ssh/ssh_host_rsa_key'] with allowed return codes [0] (shell=False, capture=True)
2016-02-09 15:54:57,588 - util.py[DEBUG]: Running command ['ssh-keygen', '-t', 'dsa', '-N', '', '-f', '/etc/ssh/ssh_host_dsa_key'] with allowed return codes [0] (shell=False, capture=True)
2016-02-09 15:54:57,683 - util.py[DEBUG]: Running command ['ssh-keygen', '-t', 'ecdsa', '-N', '', '-f', '/etc/ssh/ssh_host_ecdsa_key'] with allowed return codes [0] (shell=False, capture=True)
2016-02-09 15:54:57,685 - util.py[DEBUG]: Running command ['ssh-keygen', '-t', 'ed25519', '-N', '', '-f', '/etc/ssh/ssh_host_ed25519_key'] with allowed return codes [0] (shell=False, capture=True)

But this instance was started a few minutes before:

2016-02-09 15:43:05,257 - util.py[DEBUG]: Running command ['ssh-keygen', '-t', 'rsa', '-N', '', '-f', '/etc/ssh/ssh_host_rsa_key'] with allowed return codes [0] (shell=False, capture=True)
2016-02-09 15:43:05,326 - util.py[DEBUG]: Running command ['ssh-keygen', '-t', 'dsa', '-N', '', '-f', '/etc/ssh/ssh_host_dsa_key'] with allowed return codes [0] (shell=False, capture=True)
2016-02-09 15:43:05,510 - util.py[DEBUG]: Running command ['ssh-keygen', '-t', 'ecdsa', '-N', '', '-f', '/etc/ssh/ssh_host_ecdsa_key'] with allowed return codes [0] (shell=False, capture=True)
2016-02-09 15:43:05,513 - util.py[DEBUG]: Running command ['ssh-keygen', '-t', 'ed25519', '-N', '', '-f', '/etc/ssh/ssh_host_ed25519_key'] with allowed return codes [0] (shell=False, capture=True)

Is that a feature?

Faizan (Google Cloud Support)

unread,
Feb 10, 2016, 5:25:43 PM2/10/16
to gce-discussion
Hello Giovanni,

I was not able to reproduce this issue using my GCE instance created with "ubuntu-1404-trusty-v20160114e" image. Can you provide me your image details in order to further investigate. You can run the following command to get that image information:

gcloud compute disks describe DISK --zone ZONE | grep "sourceImage"

Thanks

Faizan
Reply all
Reply to author
Forward
0 new messages