2

I installed two ArchLinux virtual machines on my CentOS server with virt-manager on KVM. The ip addresses are 192.168.1.138 and 192.168.1.183. After installation, I installed OpenSSH and copied the SSH Keys. I tried logging in and was successful.

Then I rebooted the virtual machines and started them with virsh commands. That's when I got "Connection refused" error when I tried to log in using ssh. Pinging the VMs shows the networks is working fine.

255 hans@archie ~ % ssh root@arch1                                                                                            
ssh: connect to host arch1 port 22: Connection refused

hans@archie ~ % ssh -vv root@arch1                                                        
OpenSSH_7.8p1, OpenSSL 1.1.1  11 Sep 2018
debug1: Reading configuration data /home/hans/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "arch1" port 22
debug2: ssh_connect_direct
debug1: Connecting to arch1 [10.20.60.138] port 22.
debug1: connect to address 10.20.60.138 port 22: Connection refused
ssh: connect to host arch1 port 22: Connection refused

255 hans@archie ~ % ping arch1                                                                                             
PING arch1 (10.20.60.138) 56(84) bytes of data.
64 bytes from arch1 (10.20.60.138): icmp_seq=1 ttl=64 time=0.286 ms
64 bytes from arch1 (10.20.60.138): icmp_seq=2 ttl=64 time=0.288 ms
64 bytes from arch1 (10.20.60.138): icmp_seq=3 ttl=64 time=0.292 ms

The wired thing is if I "OPEN" the virtual machines on virt-manager and login there, then I can ssh to the VMs.

SSH keys worked fine on my 2 other CentOS servers, and the ip addresses are respectively: 192.168.1.101 and 192.168.1.202.

1
  • I just found I just need to wait for a few minutes before everything becomes normal, which still bothers me...
    – Hans Xeng
    Sep 22, 2018 at 16:59

2 Answers 2

3

I have had the same problem with Arch VMs and also found that I could either wait for 5 minutes or login via virt-manager.

Problem is with the random number generator slowing the boot:

# journalctl  --since 13:23  | grep crng
Oct 06 13:23:04 apsis kernel: random: get_random_bytes called from start_kernel+0x95/0x535 with crng_init=0
Oct 06 13:28:03 apsis kernel: random: crng init done

See https://bbs.archlinux.org/viewtopic.php?id=236696 for detail.

I followed the suggestion of installing Haveged and can now login immediately post reboot. The crng init now only takes a second instead of 5 minutes.

Hope this helps.

1

I checked OpenSSH logs with journalctl, turned out the OpenSSH server start listening to port 22 minutes after it was started:

journalctl -u sshd | tail -100

Below is some extractions:

-- Reboot --
Sep 23 00:28:47 arch3 systemd[1]: Started OpenSSH Daemon.
Sep 23 00:32:12 arch3 sshd[242]: Server listening on 0.0.0.0 port 22.
Sep 23 00:32:12 arch3 sshd[242]: Server listening on :: port 22.

-- Reboot --
Sep 23 00:46:03 arch1 systemd[1]: Started OpenSSH Daemon.
Sep 23 00:51:16 arch1 sshd[249]: Server listening on 0.0.0.0 port 22.
Sep 23 00:51:16 arch1 sshd[249]: Server listening on :: port 22.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .