Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Command to exit the ssh session #3125

Closed
afbjorklund opened this issue Jan 18, 2025 · 8 comments · Fixed by #3331
Closed

Command to exit the ssh session #3125

afbjorklund opened this issue Jan 18, 2025 · 8 comments · Fixed by #3331
Labels

Comments

@afbjorklund
Copy link
Member

afbjorklund commented Jan 18, 2025

Description

By default, the ssh connection to the lima instance is kept open between commands. (the ssh.sock)

But this also means that you don't get a new session, if environment changes or any groups are added.

So if you change the prompt or if you add a docker group, it is not reflected in the ongoing shell.

Historically I just deleted the socket, but it could be nice with a limactl shell option to exit nicely?


$ ssh -F $(limactl ls --format='{{.SSHConfigFile}}' docker) lima-docker -O exit
Exit request sent.

Then the next login will be "fresh" again.

EDIT: There is a function in sshocker do to it, called ssh.ExitMaster

For lima, we might want to restart it again as part of the hostagent?

And to re-establish the reverse-sshfs mounts (if any), and so on (ports).

This could also be useful in other places, like after resume from sleep:

@afbjorklund
Copy link
Member Author

afbjorklund commented Jan 19, 2025

There is another command called check, which will print the current status:

$ ssh -F $(limactl ls --format='{{.SSHConfigFile}}' docker) lima-docker -O check
Master running (pid=425902)

This process doesn't seem to be recorded anywhere else, i.e. there is no ssh.pid

But it's not too hard to find it: ssh: /home/anders/.lima/docker/ssh.sock [mux]

@afbjorklund

This comment has been minimized.

@afbjorklund

This comment has been minimized.

@AkihiroSuda AkihiroSuda added the area/cli limactl CLI user experience label Jan 20, 2025
@AkihiroSuda
Copy link
Member

AkihiroSuda commented Jan 20, 2025

I fear how this affects reverse-sshfs mounts (as well as port forwards)

@afbjorklund
Copy link
Member Author

There are known workarounds for the issues, like sourcing the profile again or starting a new shell with newgrp.

The brute force approach is to do a restart (sorry stop and start), but some kind of host-agent reload perhaps?

@unsuman
Copy link
Contributor

unsuman commented Mar 3, 2025

@afbjorklund Hi! I want to work on this issue and I've been able to reproduce it. I'm considering adding a new command, something like limactl restart <instance name> or limactl shell --restart. However, I'm unsure whether I should perform a hostagent reload(then I guess I have to tinker with guestservice.proto file) or a full VM restart. Does this approach seem appropriate, and am I on the right track?

@afbjorklund
Copy link
Member Author

Having a restart command (reboot VM) is a separate issue, and more of a convenience. This was "only" SSH (and friends)

@unsuman
Copy link
Contributor

unsuman commented Mar 10, 2025

Having a restart command (reboot VM) is a separate issue, and more of a convenience. This was "only" SSH (and friends)

I have implemented a restart command in #3323 and will add an option to the shell command to exit ssh sessions in a different PR.

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

Successfully merging a pull request may close this issue.

3 participants