-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
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.
- batchai (safe):
azure-cli/src/command_modules/azure-cli-batchai/azure/cli/command_modules/batchai/custom.py
Line 604 in 5a11b04
def _generate_ssh_keys(): - vm create (unsafe):
azure-cli/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_validators.py
Line 863 in 008b199
def validate_ssh_key(namespace):
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/Linuxazure-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