Skip to content

vm create --generate-ssh-keys is unsafe #6780

@dctucker

Description

@dctucker

Describe the bug

When running vm create --generate-ssh-keys, the logic of whether to overwrite keys is not as safe as used elsewhere in the product. This has caused us some turbulence with our CI builds, as we do include a private key but not a public key in our build servers, and running with --generate-ssh-keys causes our keys to get wiped out.

Ideally, the same logic from batchai custom would be implemented for vm create so a warning is shown when a key is present.

To Reproduce
Have ~/.ssh/id_rsa but not ~/.ssh/id_rsa.pub in your home folder
Run vm create --generate-ssh-keys ....
~/.ssh/id_rsa is overwritten without warning.

Expected behavior
Show a warning when a private and/or public key exists and bail.

Environment summary

  • Linux REDACTED.github.net 4.9.0-0.bpo.5-amd64 #1 SMP Debian 4.9.65-3+deb9u2~bpo8+1 (2017-01-05) x86_64 GNU/Linux
  • azure-cli (2.0.29)

Additional context

Further improvement would involve using different naming convention for the keypair used by the VM, or at least allow a different naming convention to be specified (possibly via --ssh-key-value since defaulting to id_rsa[.pub] can severely affect the a user's machine.

/cc @anth1y

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions