-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enter running machine as systemd service #123
Comments
Having same issue, maybe a sshd service might work, but is there any easier way ( like a tty directly ) ? |
If you look into git history, this existed as I am happy to have consoles/serials configurable but with sensible defaults. I cannot give an ETA when I'll have time for that. Also, I am delighted that @Mic92 has updated https://github.com/Mic92/vmsh -- please play with that! |
Thanks, but |
I think I would need more time to fix some issues with VMSH.
I allocate an tap interface called "management" to each vm (on the host I use {
# Only allow ssh on internal tap devices
networking.firewall.interfaces.management.allowedTCPPorts = [ 22 ];
services.openssh.openFirewall = false;
} Than I set the link-local ipv6 address to "fe80::1" on the host and "fe80::2" in the VM. I can than use this ssh wrapper to access my machine: {
environment.systemPackages = [
(pkgs.writeScriptBin "ssh-vm" ''
#!/usr/bin/env bash
if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 <vm-name>"
exit 1
fi
vm=$1
shift
# we can disable host key checking because we use ipv6 link local addresses and no other vm can spoof them on this interface
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$@" root@fe80::2%mgt-$vm
'')
];
} This allows me to login by using the VM name: $ ssh-vm foo |
Systemd also now parses terminal name and size from the kernel command line, but this would be mainly useful for the initial terminal at boot time and not for ad-hoc ones: https://github.com/systemd/systemd/blob/6ac299e3cedb1d9eb8df88010c4994a90aa12a9a/NEWS#L144 |
A future version of systemd will make it easy to connect to a running VM over VSOCK: systemd/systemd#30777 which this project can use! |
I just came across this issue on my configuration. For me, @Mic92's solution, with SSH over IPv6, did not work. I instead changed the Qemu parameters to forward I have these changes in this branch: https://github.com/jim3692/microvm.nix/tree/console-in-unix-sock I have also implemented the EDIT: My VM's IPv6 is |
I prefer waiting for ssh over vsock rather than bringing back what we had before with BTW, find your machine's link-local addresses by pinging |
This is doable today. In your host:
In your guest:
Then, to connect to your guest from your host:
|
This approach works with the default qemu VMM, but not with e.g. cloud-hypervisor, as it's terminating the vsock connection differently [1]. Is there a way to use an approach like this with cloud-hypervisor's implementation of vsock? |
Is it possible to connect terminal stdin/stdout to deployed machine, to inspect what's going on there?
The text was updated successfully, but these errors were encountered: