Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arighi
Copy link
Owner

@arighi arighi commented Dec 31, 2024

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.

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>
Copy link
Collaborator

@matttbe matttbe left a 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)?;
Copy link
Collaborator

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.

Copy link
Owner Author

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.

Copy link
Collaborator

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? :-/

Copy link
Collaborator

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.

Copy link
Owner Author

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.

Copy link
Collaborator

@matttbe matttbe Dec 31, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants