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

new command: limactl show-ssh --format=(cmd|args|options|config) INSTANCE #338

Merged
merged 3 commits into from
Oct 18, 2021

Conversation

AkihiroSuda
Copy link
Member

@AkihiroSuda AkihiroSuda commented Oct 15, 2021

limactl show-ssh --format=cmd INSTANCE (default format) : Full ssh command line.

ssh -o IdentityFile="/Users/suda/.lima/_config/user" -o IdentityFile="/Users/suda/.ssh/id_ed25519" -o IdentityFile="/Users/suda/.ssh/id_rsa" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NoHostAuthenticationForLocalhost=yes -o GSSAPIAuthentication=no -o PreferredAuthentications=publickey -o Compression=no -o BatchMode=yes -o IdentitiesOnly=yes -o Ciphers="^aes128-gcm@openssh.com,aes256-gcm@openssh.com" -o User=suda -o ControlMaster=auto -o ControlPath="/Users/suda/.lima/default/ssh.sock" -o ControlPersist=5m -o Hostname=127.0.0.1 -o Port=60022 lima-default

limactl show-ssh --format=args INSTANCE: Similar to the cmd format but omits "ssh" and the destination address

-o IdentityFile="/Users/suda/.lima/_config/user" -o IdentityFile="/Users/suda/.ssh/id_ed25519" -o IdentityFile="/Users/suda/.ssh/id_rsa" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NoHostAuthenticationForLocalhost=yes -o GSSAPIAuthentication=no -o PreferredAuthentications=publickey -o Compression=no -o BatchMode=yes -o IdentitiesOnly=yes -o Ciphers="^aes128-gcm@openssh.com,aes256-gcm@openssh.com" -o User=suda -o ControlMaster=auto -o ControlPath="/Users/suda/.lima/default/ssh.sock" -o ControlPersist=5m -o Hostname=127.0.0.1 -o Port=60022

limactl show-ssh --format=options INSTANCE: ssh option key value pairs

IdentityFile="/Users/suda/.lima/_config/user"
IdentityFile="/Users/suda/.ssh/id_ed25519"
IdentityFile="/Users/suda/.ssh/id_rsa"
StrictHostKeyChecking=no
UserKnownHostsFile=/dev/null
NoHostAuthenticationForLocalhost=yes
GSSAPIAuthentication=no
PreferredAuthentications=publickey
Compression=no
BatchMode=yes
IdentitiesOnly=yes
Ciphers="^aes128-gcm@openssh.com,aes256-gcm@openssh.com"
User=suda
ControlMaster=auto
ControlPath="/Users/suda/.lima/default/ssh.sock"
ControlPersist=5m
Hostname=127.0.0.1
Port=60022

limactl show-ssh --format=config INSTANCE: ~/.ssh/config format

Host lima-default
  IdentityFile "/Users/suda/.lima/_config/user"
  IdentityFile "/Users/suda/.ssh/id_ed25519"
  IdentityFile "/Users/suda/.ssh/id_rsa"
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  NoHostAuthenticationForLocalhost yes
  GSSAPIAuthentication no
  PreferredAuthentications publickey
  Compression no
  BatchMode yes
  IdentitiesOnly yes
  Ciphers "^aes128-gcm@openssh.com,aes256-gcm@openssh.com"
  User suda
  ControlMaster auto
  ControlPath "/Users/suda/.lima/default/ssh.sock"
  ControlPersist 5m
  Hostname 127.0.0.1
  Port 60022

Usage:

$ limactl show-ssh --format=config default >> ~/.ssh/config
$ ssh lima-default

@AkihiroSuda AkihiroSuda added this to the v0.7.2 milestone Oct 15, 2021
@jandubois
Copy link
Member

Not sure about the general utility of this command, but am not opposed to it. Should probably support an extra --format=url to cover @afbjorklund's "nice to have" from #322 (comment):

Having a similar variable available for the entire SSH URL directly would also be "nice to have".

With a proper ssh:// and the human template's fmt.Sprintf("127.0.0.1:%d", inst.SSHLocalPort)

I could only find a long expired RFC draft specifying the ssh:// URL scheme, and it seems like nobody implements it except for the most basic form ssh://host:port, which is also what Docker seems to support.

@jandubois
Copy link
Member

"Usage" message shows "[flags]" in wrong position:

$ limactl show-ssh --help | grep -A1 Usage
Usage:
  limactl show-ssh INSTANCE [flags]

$ limactl show-ssh default -f options
FATA[0000] accepts 1 arg(s), received 3

$ limactl show-ssh -f options default
IdentityFile="/Users/jan/.lima/_config/user"
...

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
…TANCE`

e.g.,
```
$ limactl show-ssh --format=config default >> ~/.ssh/config
$ ssh lima-default
```

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda
Copy link
Member Author

AkihiroSuda commented Oct 18, 2021

url

Not in this PR, but feel free to open an issue/PR

Usage

fixed

Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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