"qemu+ssh..." only works with PasswordAuthentication yes in sshd_config

109 Views Asked by At

I can SSH from laptop to server with private/public key like this:

$ ssh -i ~/.ssh/ed25519 [email protected] -p 22XX

My public key is on the SERVER in ~/.ssh/authorized_keys.

When I try virsh I cannot connect:

$ virsh -c qemu+ssh://[email protected]:22XX/system

error: failed to connect to the hypervisor
error: Cannot recv data: [email protected]: Permission denied (publickey).: Connection reset by peer

I changed PasswordAuthentication yes in sshd_config and am able to connect to SERVER with the above command.

But the problem is now I have SSH password authentication on my server that I don't want.

Here is the journalctl from LAPTOP attempting to connect without password:

$ journalctl --lines=100

Jan 25 18:06:05 arch polkitd[462]: Registered Authentication Agent for unix-process:1237:24897 (system bus name :1.52 [/usr/bin/pkttyagent --process 1237 --notify-fd 4 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
Jan 25 18:06:05 arch polkitd[462]: Unregistered Authentication Agent for unix-process:1237:24897 (system bus name :1.52, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)

I don't have polkit.service running on either LAPTOP or SERVER. And I changed libvirtd_config to have auth_rw="none" and auth_ro="none" and I have qemu-ssh-block-agent package installed.

Please help.

1

There are 1 best solutions below

1
chuckd833 On

I had a suggestion to use ssh-agent which I had tried yesterday but wasn't successful. I rebooted the server and laptop retried ssh-agent and it was able to connect last night.

For others: I ran it through my LAPTOP:

[[email protected]][~]
$  ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXN8xmnw/agent.1538; export SSH_AUTH_SOCK;
SSH_AGENT_PID=1539; export SSH_AGENT_PID;
echo Agent pid 1539;

[[email protected]][~]
$  eval $(ssh-agent -c)      //fish needs -c
Agent pid 1569

[[email protected]][~]
$  ssh-add ~/.ssh/ed25519
Identity added: /home/chris/.ssh/ed25519 (chris@arch)

[[email protected]][~]
$  virsh -c qemu+ssh://[email protected]:220/system
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # 

The only issue that remains is that from virt-manager GUI I still receive the same connection issue. So I have to start that with:

virt-manager -c qemu+ssh://[email protected]:220/system