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

[Compute] Incorrect permissions assigned private ssh key when creating a Linux VM #16843

Closed
dcaro opened this issue Jan 14, 2022 · 15 comments
Closed
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Compute - VM Service Attention This issue is responsible by Azure service team.

Comments

@dcaro
Copy link
Contributor

dcaro commented Jan 14, 2022

Description

The ssh private key created when running a command like the following one is saved with incorrect permissions.
New-AzVM -name LinuxVM -ResourceGroupName "linuxvm" -Image UbuntuLTS -PublicIpAddressName linuxvmip-SshKeyName linuxvmsshkey -GenerateSshKey -Credential $cred

ssh is expecting permissions to be 600 for the .ssh/privatekey but on MacOs or cloudshell, the file has a 644 permission.

Depending on the OS on which this cmdlet is used, the permissions should be adjusted accordingly.
https://github.com/Azure/azure-powershell/blob/main/src/Compute/Compute/Usage/NewAzureSshKey.cs#L78

Issue script & Debug output

PS /home/damien> ssh -i /home/damien/.ssh/1234567890 azureuser@linuxvm2-31e243.westus.cloudapp.azure.com
load pubkey "/home/damien/.ssh/1234567890": invalid format
The authenticity of host 'linuxvm2-31e243.westus.cloudapp.azure.com (137.135.9.228)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'linuxvm2-31e243.westus.cloudapp.azure.com,137.135.9.228' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/damien/.ssh/1234567890' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/home/damien/.ssh/1234567890": bad permissions
[email protected]: Permission denied (publickey).

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Linux 5.4.0-1065-azure #68~18.04.1-Ubuntu SMP Fri Dec 3 14:08:44 UTC 2021
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

The environment is cloudshell.

Error output

No response

@dcaro dcaro added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jan 14, 2022
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Jan 14, 2022
@dcaro dcaro added Compute - VM Service Attention This issue is responsible by Azure service team. labels Jan 14, 2022
@ghost
Copy link

ghost commented Jan 14, 2022

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @avirishuv.

Issue Details

Description

The ssh private key created when running a command like the following one is saved with incorrect permissions.
New-AzVM -name LinuxVM -ResourceGroupName "linuxvm" -Image UbuntuLTS -PublicIpAddressName linuxvmip-SshKeyName linuxvmsshkey -GenerateSshKey -Credential $cred

ssh is expecting permissions to be 600 for the .ssh/privatekey but on MacOs or cloudshell, the file has a 644 permission.

Depending on the OS on which this cmdlet is used, the permissions should be adjusted accordingly.
https://github.com/Azure/azure-powershell/blob/main/src/Compute/Compute/Usage/NewAzureSshKey.cs#L78

Issue script & Debug output

PS /home/damien> ssh -i /home/damien/.ssh/1234567890 azureuser@linuxvm2-31e243.westus.cloudapp.azure.com
load pubkey "/home/damien/.ssh/1234567890": invalid format
The authenticity of host 'linuxvm2-31e243.westus.cloudapp.azure.com (137.135.9.228)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'linuxvm2-31e243.westus.cloudapp.azure.com,137.135.9.228' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/damien/.ssh/1234567890' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/home/damien/.ssh/1234567890": bad permissions
[email protected]: Permission denied (publickey).

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Linux 5.4.0-1065-azure #68~18.04.1-Ubuntu SMP Fri Dec 3 14:08:44 UTC 2021
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

The environment is cloudshell.

Error output

No response

Author: dcaro
Assignees: -
Labels:

Compute - VM, Service Attention, bug

Milestone: -

@avirishuv
Copy link

hi @oriwolman could you please take a look at this issue?

@jaylabell
Copy link

Looking into this issue.

@jaylabell
Copy link

Still investigating this fix

@oriwolman oriwolman assigned jaylabell and unassigned oriwolman May 19, 2022
@jaylabell
Copy link

@dcaro - Hi Damien, we are committed to this fix for the current Sprint.
@haagha - Haider is looking into it!

Lastly, can you both refer to the following work item for more timely updates and discussion?

@haagha
Copy link
Member

haagha commented Oct 6, 2022

@Sandido will be looking into this.

@haagha haagha assigned Sandido and haagha and unassigned haagha Oct 6, 2022
@haagha
Copy link
Member

haagha commented Oct 10, 2022

I will be looking into this.

@jaylabell
Copy link

@haagha Do you have an update on this item?

@Drewm3 Drewm3 assigned Drewm3 and unassigned jaylabell Feb 9, 2023
@Drewm3
Copy link
Member

Drewm3 commented Feb 9, 2023

Moving Jayla's issues over to me.

@Drewm3
Copy link
Member

Drewm3 commented Mar 13, 2023

I am working with the dev team to get this picked up.

@Drewm3
Copy link
Member

Drewm3 commented Jul 27, 2023

@haagha, should this update be in the current cmdlets now? If not, then when should the fix be available?

@haagha
Copy link
Member

haagha commented Aug 1, 2023

@Drewm3 This should be available in the September release.

@Drewm3
Copy link
Member

Drewm3 commented Sep 21, 2023

Please note that this issue did not make the September release. It is now expected to be part of the October release.

@Drewm3
Copy link
Member

Drewm3 commented Nov 6, 2023

This will be released in the Nov release of PowerShell cmdlets because there was no October release.

@Sandido
Copy link
Member

Sandido commented Aug 29, 2024

Feature was released, closing this item.

@Sandido Sandido closed this as completed Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Compute - VM Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

7 participants