ssh handshake fails with qemu kvm ubuntu 14

622 views
Skip to first unread message

MrZogs

unread,
Apr 25, 2015, 8:00:56 PM4/25/15
to packe...@googlegroups.com
Hi all.

I have and Ubuntu 14 qemu/kvm host. I can create VMs using virt-install and virt-manager etc, but I wanted something better so I'm trying to learn Packer.

Here's my template file.

root@landrew:/home/msh/packer# less centos7-packer0.json 

{

 

 
"builders":

 
[

   
{

     
"type": "qemu",

     
"iso_url": "http://ns1.plz.yo/iso/centos/CentOS-7.0-1406-x86_64-Minimal.iso",

     
"iso_checksum": "e3afe3f1121d69c40cc23f0bafa05e5d",

     
"iso_checksum_type": "md5",

     
"output_directory": "/store0/libvirt/pools/default/packerd-fudge",

     
"ssh_wait_timeout": "30s",

     
"shutdown_command": "shutdown -P now",

     
"disk_size": 1600,

     
"format": "qcow2",

     
"headless": true,

     
"accelerator": "kvm",

     
"http_directory": "httpdir",

     
"http_port_min": 10082,

     
"http_port_max": 10089,

     
"ssh_host_port_min": 33000,

     
"ssh_host_port_max": 33654,

     
"ssh_username": "msh",

     
"ssh_password": "p4sSw3rdZ",

     
"ssh_port": 22,

     
"ssh_wait_timeout": "90m",

     
"vm_name": "plz-test0",

     
"net_device": "virtio-net",

     
"disk_interface": "virtio",

     
"boot_wait": "5s",

     
"boot_command":

     
[

       
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/kickstart/centos7ks.cfg<enter><wait>"

     
]

   
}

 
]

}


And my kickstart file looks like this:

install

 

lang en_US
.UTF-8

keyboard us

network
--bootproto=dhcp --device=eth0 --gateway=192.168.10.1 --hostname=centos7 --nameserver=192.168.10.1

# packages location

url
--url=http://ns1.plz.yo/iso/centos/CentOS-7.0-1406-x86_64-Minimal.iso

rootpw
--iscrypted shG2ReAKHuU1M

# where password above is created with "python -c 'import crypt; print(crypt.crypt("mypassword", "sha256sum"))'"

# one may alter "mypassword" and sha256sum ( valid are md5sum sha1sum sha224sum sha256sum sha384sum sha512sum shasum )

firewall
--service=ssh

authconfig
--enableshadow --passalgo=sha512 --enablefingerprint

selinux
--enforcing

timezone
--utc Etc/UTC

bootloader
--location=mbr

#disk part

clearpart
--all --initlabel

part
/ --fstype=xfs --asprimary --size=8000

part
/var --fstype=xfs --size=4000

part
/boot --fstype=ext4 --size=200

part swap
--size=300 --asprimary

# packages we want to install, in my case I do minimal installation due to speed

%packages

@base

@core

chrony

createrepo

%end


 The error I'm getting is: 
 

2015/04/25 19:54:24 packer-builder-qemu: 2015/04/25 19:54:24 Attempting SSH connection...

2015/04/25 19:54:24 packer-builder-qemu: 2015/04/25 19:54:24 reconnecting to TCP connection for SSH

2015/04/25 19:54:24 packer-builder-qemu: 2015/04/25 19:54:24 handshaking with SSH

2015/04/25 19:54:43 packer-builder-qemu: 2015/04/25 19:54:43 handshake error: ssh: handshake failed: read tcp 127.0

.0.1:33615: connection reset by peer

2015/04/25 19:54:43 packer-builder-qemu: 2015/04/25 19:54:43 SSH handshake err: ssh: handshake failed: read tcp 127

.0.0.1:33615: connection reset by peer

I could start speculating but does anyone know what's happening? I have iptables turned off on the host machine.  

 

Alvaro Miranda Aguilera

unread,
Apr 25, 2015, 8:15:49 PM4/25/15
to packe...@googlegroups.com
Hello,

Removing qemu from the picture, I don't see how that user msh is being created.

I think you should use

"ssh_username": "root",

"ssh_password": "p4sSw3rdZ",


You can also use a plain text pass in the kickstart

rootpw root

and then use

"ssh_username": "root",

"ssh_password": "root",

Then later you can put a more secure/enforced password.

Hope this helps

Alvaro.
> --
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to packer-tool...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

MrZogs

unread,
Apr 25, 2015, 8:52:39 PM4/25/15
to packe...@googlegroups.com
Nah, that didn't help. I don't think "handshake" means "password failed." I think handshake errors mean "I can't even find the sshd to talk to."

Alvaro Miranda Aguilera

unread,
Apr 25, 2015, 8:58:50 PM4/25/15
to packe...@googlegroups.com
ok, this is suggestion 1.

add reboot after keyboard

by default, the installer wait to confirm reboot

suggestion 2.

if you want to keep nic as eth0/eth1

you can add

bootloader --location=mbr --boot-drive=sda --append="net.ifnames=0
biosdevname=0"

suggestion 3

Change packer template to root / p4sSw3rdZ for user/pass

Alvaro.

MrZogs

unread,
Apr 25, 2015, 9:48:33 PM4/25/15
to packe...@googlegroups.com
Packer seems to be attempting to connect to 127.0.0.1 which doesn't make sense to me. Then again, sshd _is_ listening on the loopback.
Another detail, my kvm host machine is set up to run all it's VMs as bridged guests. 
Reply all
Reply to author
Forward
0 new messages