Skip to content

Commit

Permalink
[Compute] Revert Generate-SSH file permission changes because of Clou…
Browse files Browse the repository at this point in the history
…dshell failure (#23477)

* reverting changes for file permissions of private key using New-Azvm

* Update ChangeLog.md

---------

Co-authored-by: NoriZC <[email protected]>
  • Loading branch information
haagha and NoriZC authored Nov 28, 2023
1 parent 33cff08 commit e4e2930
Show file tree
Hide file tree
Showing 4 changed files with 800 additions and 974 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public void TestCapacityReservation()
TestRunner.RunTestScript("Test-CapacityReservation");
}

[Fact(Skip = "Cannot run on Github Platform due to ACL API")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVMwithSSHKey()
{
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Added new examples in `New-AzVM` and `New-AzVmss` for TrustedLaunch default usage.
* Fixed the `New-AzVM` bug to avoid accessing the `EncryptionAtHost` property for subscriptions who cannot access it since it is behind a feature flag.
* Updated `Get-AzVmExtension` to return instanceView when used with `-Status`.
* Reverted SSH Private Key File permission changes in `New-AzVm`.

## Version 7.0.0
* Added update functionality in `Update-AzVmss` for parameters `SecurityType`, `EnableSecureBoot`, and `EnableVtpm` for the parameter set with the Put operation.
Expand Down
17 changes: 0 additions & 17 deletions src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1566,23 +1566,6 @@ private string GenerateOrFindSshKey()
}
Console.WriteLine("Private key is saved to " + privateKeyFilePath);

FileSecurity fileSecurity = new FileSecurity(privateKeyFilePath, AccessControlSections.Access);
// Define the owner's identity
IdentityReference owner = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null);

// Create an access rule for the owner with read and write permissions (0600)
FileSystemAccessRule rule = new FileSystemAccessRule(
owner,
FileSystemRights.Read | FileSystemRights.Write,
AccessControlType.Allow
);

// Add the access rule to the file security
fileSecurity.AddAccessRule(rule);

FileInfo fileinfo = new FileInfo(privateKeyFilePath);
fileinfo.SetAccessControl(fileSecurity);

using (StreamWriter writer = new StreamWriter(publicKeyFilePath))
{
writer.WriteLine(keypair.PublicKey);
Expand Down

0 comments on commit e4e2930

Please sign in to comment.