I am trying to build a custom Ubuntu (ISO built from bionic - 18.04.2
) qcow2 image via packer
. This fails in the step where packer
tries to SSH to the instance via port forward.
I can see from VNC that the instance spins up fine, and I can login with the given ID manually on the console, but packer
is unable to ssh.
I tried to ssh, ssh
form host gets stuck for a long time and errors out:
ssh -vvv -p 2226 admin@127.0.0.1
debug1: identity file /home/ani/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4
Though the port is up:
$ sudo lsof -i:2226
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
qemu-syst 31185 root 14u IPv4 50059412 0t0 TCP *:2226 (LISTEN)
SSH server is running in the instance, and the user is a valid one. What else do I need to check to ensure SSH can happen via the host ?
On the same host, I am able to make Ubuntu Trusty (14.04
) qcow2. So, I am not sure if some additional qemu command line arguments need to be passed (for port forwarding to work correctly)
Or some sshd
configs need to be changed on Ubuntu bionic (18.04
)!
This is the qemu command line:
/usr/bin/qemu-system-x86_64 -cpu host -smp 4 -m 8192M -boot once=d -name ubuntu-bionic-custom-0.1.qcow2 -drive file=output/ubuntu-bionic-custom-0.1.qcow2,if=virtio,cache=writeback,discard=ignore,format=qcow2 -serial file:serial.out -device e1000,netdev=user.0 -machine type=pc,accel=kvm -netdev user,id=user.0,hostfwd=tcp::2226-:22 -cdrom /home/ani/ubuntu-bionic-custom-0.1.iso -vnc 127.0.0.1:83
version:
$ /usr/bin/qemu-system-x86_64 --version
QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.4)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
--EDIT--
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.192.0.1 0.0.0.0 UG 0 0 0 br0
10.0.3.0 0.0.0.0 255.255.255.0 U 0 0 0 lxcbr0
10.192.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
$ ip netns ls
$