Skip to content

Commit 0999351

Browse files
committed
skip chmod on windows
1 parent ce43061 commit 0999351

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/core/src/awsService/ec2/sshKeyPair.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5-
import { fs } from '../../shared'
5+
import os from 'os'
6+
import { fs, globals } from '../../shared'
67
import { ToolkitError } from '../../shared/errors'
78
import { tryRun } from '../../shared/utilities/pathFind'
89
import { Timeout } from '../../shared/utilities/timeoutUtils'
@@ -37,7 +38,11 @@ export class SshKeyPair {
3738
if (!keyGenerated || !(await fs.existsFile(keyPath))) {
3839
throw new ToolkitError('ec2: Unable to generate ssh key pair')
3940
}
40-
await fs.chmod(keyPath, 0o600)
41+
// Should already be the case, but just in case we assert permissions.
42+
// skip on Windows since it only allows write permission to be changed.
43+
if (!globals.isWeb && os.platform() !== 'win32') {
44+
await fs.chmod(keyPath, 0o600)
45+
}
4146
}
4247
/**
4348
* Attempts to generate an ssh key pair. Returns true if successful, false otherwise.

0 commit comments

Comments
 (0)