-
Notifications
You must be signed in to change notification settings - Fork 9
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
ssh: enable empty password login for all users #16
base: main
Are you sure you want to change the base?
Conversation
Disabling password login for all users is unnecessary, as the virtme-ng instance is intended solely for testing purposes. In fact, enabling empty password for all users can be quite convenient and does not pose a security risk, since all filesystem access is ultimately handled by the host user (due to virtiofsd running as the host user). In particular, enabling empty password login eliminates the need for managing ssh authorized keys, simplifying the configuration further. Signed-off-by: Andrea Righi <arighi@nvidia.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
But if we decide to take this direction, please modify how we are using hostfwd
's QEmu option: by default, it will create a listening socket that is accessible from the network. Best to restrict it to localhost.
According to QEmu's doc:
hostfwd=[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport
So instead of:
"hostfwd=tcp::%d-:22" % args.port
We should probably have:
"hostfwd=tcp:127.0.0.1:%d-:22" % args.port
In particular, enabling empty password login eliminates the need for managing ssh authorized keys, simplifying the configuration further.
Will you remove this code as well?
@@ -315,7 +315,7 @@ fn generate_shadow() -> io::Result<()> { | |||
|
|||
for line in reader.lines() { | |||
if let Some((username, _)) = line?.split_once(':') { | |||
writeln!(writer, "{}:!:::::::", username)?; | |||
writeln!(writer, "{}::::::::", username)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to be sure: is it OK to do that with "system" users? e.g. the ones having nologin
or false
for the shell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You raised a valid point... even with localhost only another user might be able to ssh into the guest, potentially having access to data that was only visible to the user that started the vng instance.
So this change seems to have security implications and it's probably safer to stick with the public key authentication.
I'll think more about this, but I'm more inclined to drop this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even with localhost only another user might be able to ssh into the guest, potentially having access to data that was only visible to the user that started the vng instance.
Good point. But then, do we not have the same issue with the VSOCK option? :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any cases, we should restrict the SSH connection to localhost only by default I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any kind of permission restriction with vsock? If not we should mention it in the README or the help.
Maybe we should consider vsock a quick (but potentially unsafe) way to connect to the vng instance and if you need better security use ssh.
And yes, we definitely need to restrict access to localhost only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any kind of permission restriction with vsock? If not we should mention it in the README or the help.
It looks like we have some restrictions with the current code "by accident": when starting the VM, an empty script file will be created (by default /tmp/virtme-console/2222.sh
) and only the current user can modify it. So we can connect to the vsock, but nothing will happen apart from executing an empty script. Looks enough, no?
If we want something more secure, it looks like QEmu can take a Unix socket in argument in order not to have the CID accessible to everybody on the machine (via /dev/vhost-vsock
), but I didn't really find a lot of documentation about that, except this Rust VMM project that seems to be using a Unix socket. Do you think it is worth investigating? It feels like what we have for the moment is enough.
Now regarding SSH, maybe warning the user in the README/help menu is enough for the moment?
Disabling password login for all users is unnecessary, as the virtme-ng instance is intended solely for testing purposes.
In fact, enabling empty password for all users can be quite convenient and does not pose a security risk, since all filesystem access is ultimately handled by the host user (due to virtiofsd running as the host user).
In particular, enabling empty password login eliminates the need for managing ssh authorized keys, simplifying the configuration further.