trying to generate ssh keys of the vm but getting the error option requires an argument -- P

trying to generate ssh keys of the vm but getting the error option requires an argument -- P

I have executed the below command manually in the vm and i am able to generate the ssh keys but when i tried using the same script in the automation pipeline from github actions i am getting the error

Script: name: Azure CLI script

           uses: azure/CLI@v1

           with:

           inlineScript: |
    
            az vm run-command invoke --command-id RunShellScript -g "${{ env.RESOURCEGROUPNAME }}" -n "${{ env.VM_NAME }}"  --scripts "chmod 700 /home/adminuser/.ssh && ssh-keygen -t rsa -f /home/adminuser/.ssh/id_rsa -P """

error: \n[stdout]\n\n[stderr]\noption requires an argument -- P\r\nusage: ssh-keygen [-q] [-b bits] [-C comment] [-f output_keyfile] [-m format]\n [-t dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa]\n [-N new_passphrase] [-O option] [-w provider]\n ssh-keygen -p [-f keyfile] [-m format] [-N new_passphrase]\n [-P old_passphrase]\n ssh-keygen -i [-f input_keyfile] [-m key_format]\n ssh-keygen -e [-f input_keyfile] [-m key_format]\n

答案1

May be use single quote instead of double. Or Vise Versa for the Password field.

'chmod 700 /home/adminuser/.ssh && ssh-keygen -t rsa -f /home/adminuser/.ssh/id_rsa -P "" '

or

"chmod 700 /home/adminuser/.ssh && ssh-keygen -t rsa -f /home/adminuser/.ssh/id_rsa -P '' "

相关内容