Fix pubkey permissions

This commit is contained in:
crschnick
2025-08-15 04:27:26 +00:00
parent b1759cd2a5
commit b23f5d5993
@@ -57,6 +57,11 @@ public interface SshIdentityStrategy {
var base = LocalShell.getShell().getSystemTemporaryDirectory().join("key.pub");
var file = LocalShell.getShell().view().writeTextFileDeterministic(base, publicKey.strip() + "\n");
if (OsType.getLocal() != OsType.WINDOWS) {
LocalShell.getShell().command(CommandBuilder.of().add("chmod", "400").addFile(file)).executeAndCheck();
}
return Optional.of(file);
}
@@ -332,7 +337,7 @@ public interface SshIdentityStrategy {
+ " is marked to be a public key file, SSH authentication requires the private key"));
}
if ((parent.getOsType() == OsType.LINUX || parent.getOsType() == OsType.MACOS)) {
if (parent.getOsType() != OsType.WINDOWS) {
// Try to preserve the same permission set
parent.command(CommandBuilder.of()
.add("test", "-w")