Azure / iotedgedev

The Azure IoT Edge Dev Tool greatly simplifies your Azure IoT Edge development process. It has everything you need to get started and helps with your day-to-day Edge development.
https://aka.ms/iotedgedev
Other
160 stars 70 forks source link

Manual DEV machine setup described in https://github.com/Azure/iotedgedev/blob/main/docs/environment-setup/manual-dev-machine-setup.md is not working as expected #605

Open emulic opened 1 year ago

emulic commented 1 year ago

Description

The approach described in https://github.com/Azure/iotedgedev/blob/main/docs/environment-setup/manual-dev-machine-setup.md is not fully working on windows. The executed command is according to the linked document: iotedgedev solution init --template csharp Choosing to install VM to simulate Edge Device (Create a new Virtual Machine with IoTEdge? [y/N]: y) during the execution, ends up with the following error:

SSH Key file (must be located in ~/.ssh and will be created if it doesn't exist) [id_rsa_iotedgedev]:

Creating a new Virtual Machine in 'fits4u-dev' with ssh key file 'id_rsa_iotedgedev'...

Retrieving 'SOME_DEVICE_ID' connection string...

No SSH key found at ~/.ssh/id_rsa_iotedgedev.pub. Generating a new one...

Saving key "~/.ssh/id_rsa_iotedgedev" failed: No such file or directory
ERROR: [Errno 2] No such file or directory: 'C:\\Users\\SOMEUSER\\.ssh\\id_rsa_iotedgedev.pub'
ERROR: Error while executing command: iotedgedev iothub setup --update-dotenv. Command '['iotedgedev', 'iothub', 'setup', '--update-dotenv']' returned non-zero exit status 1.

The exception comes obviously from the line 574 of azurecli.py: os.system(f("ssh-keygen -t rsa -b 4096 -C \"iotedgedev-autogenerated\" -f ~/.ssh/{ssh_key_file} -q -N \"\"")) This seems to be known issue of ssh-keygen, where ~ can't be resolved as user profile folder under windows.

Expected behavior

The command iotedgedev solution init --template csharp is successfully executed until the end and VM with Edge Device simulation is created in Azure.

Actual behavior

Execution of the command iotedgedev solution init --template csharp fails with the following error, when chosen to create a VM:

Saving key "~/.ssh/id_rsa_iotedgedev" failed: No such file or directory
ERROR: [Errno 2] No such file or directory: 'C:\\Users\\SOMEUSER\\.ssh\\id_rsa_iotedgedev.pub'
ERROR: Error while executing command: iotedgedev iothub setup --update-dotenv. Command '['iotedgedev', 'iothub', 'setup', '--update-dotenv']' returned non-zero exit status 1.

No VM is created.

Steps to Reproduce

Execute following command on Windows 10: iotedgedev solution init --template csharp Executing with Administrator privileges is also not working.

Environment

iotedgedev Version: 3.3.7 Python Version: 3.6.8 Pip Version: 21.3.1 Development machine OS Version: Windows 10 Enterprise 22H2 IoT Edge device OS Version: - (this is actually the issue, Edge Device VM is not created)

marianan commented 1 year ago

@emulic thanks for letting us know of this issue. Do you have any pointers to the ssh-keygen known issue you mentioned? What are the suggested workarounds? Also, what terminal are you running this command on? Does command prompt, Git bash and PowerShell all have this same symptom?

emulic commented 1 year ago

@marianan As far as I found, following workarounds might work (I haven't tested):

  1. To use absolute path C:\Users\UserName.ssh\ instead of ~\UserName.ssh as suggested in one of the comments here https://stackoverflow.com/questions/32910928/ssh-keygen-no-such-file-or-directory
  2. To just use file name without any path, this comment here is saying, the file will be by default saved to ~.ssh folder I tried with command prompt and PowerShell, same issue on both.