Cloned an LXC container from an existing one and then tried to connect to the new LXC through SSH and got this error:
ssh lxc24
Read from socket failed: Connection reset by peer
Logged in through lxc-console, the following error found in /var/log/auth.log describes the source of the problem pretty clear:
lxc24 login[1619]: pam_unix(login:session): session closed for user root
lxc24 sshd[1913]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
lxc24 sshd[1913]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
lxc24 sshd[1913]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Somehow during the clone process the host keys were removed. I simply recreated them using:
ssh-keygen -b 1024 -t rsa -f /etc/ssh/ssh_host_key
ssh-keygen -b 1024 -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -b 1024 -t dsa -f /etc/ssh/ssh_host_dsa_key
or as a quicker alternative, run dkpg-reconfigure openssh-server (thanks Fabien):
dpkg-reconfigure openssh-server
And the SSH login worked again (magic! lol):
ssh lxc24
Linux lxc24 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u1 x86_64
No comments yet.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Office PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder