Skip to content

Commit 6b4e921

Browse files
edbaltraCopilot
andauthored
Update src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent bc32a3b commit 6b4e921

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,14 @@ public int run() throws Exception {
614614
String privateKeyData = sshPrivateKey.replaceAll("\r\n", "\n");
615615
tempPkFile = AnsibleUtil.createTemporaryFile("","id_rsa", privateKeyData,customTmpDirPath);
616616

617-
// Set SSH private key permissions to 0400 (owner read-only).
618-
// This is a security best practice: private keys should never be writable after creation.
619-
// SSH itself will warn or refuse to use keys with overly permissive permissions (e.g., 0600).
620-
// Write permission is unnecessary since this temporary file is created once, read by SSH,
621-
// and never modified. The file will be deleted after use.
622-
// Node-specific private keys created elsewhere in this class should use the same 0400 permissions for consistency.
617+
// Set SSH private key permissions to 0600 (owner read/write).
618+
// This keeps the key private (not accessible by group/world) while preserving backward
619+
// compatibility for workflows that may need to modify or reuse this temporary file.
620+
// SSH itself will warn or refuse to use keys with overly permissive permissions, so we
621+
// restrict access to the file owner only.
623622
Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();
624623
perms.add(PosixFilePermission.OWNER_READ);
624+
perms.add(PosixFilePermission.OWNER_WRITE);
625625
Files.setPosixFilePermissions(tempPkFile.toPath(), perms);
626626

627627
if (sshUseAgent) {

0 commit comments

Comments
 (0)