RemoteLinux: Read public key more directly

Change-Id: I38faa3be91e615571f02d51a721ea858b5f70298
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2025-04-15 14:51:16 +02:00
parent 871c93f652
commit e062cba0d0

View File

@@ -67,14 +67,14 @@ PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const DeviceConstRef &devic
handleDeploymentDone(result);
});
FileReader reader;
if (!reader.fetch(publicKeyFileName)) {
handleDeploymentDone(ResultError(Tr::tr("Public key error: %1").arg(reader.errorString())));
const Result<QByteArray> publicKey = publicKeyFileName.fileContents();
if (!publicKey) {
handleDeploymentDone(ResultError(Tr::tr("Public key error: %1").arg(publicKey.error())));
return;
}
const QString command = "test -d .ssh || mkdir -p ~/.ssh && chmod 0700 .ssh && echo '"
+ QString::fromLocal8Bit(reader.data())
+ QString::fromLocal8Bit(publicKey.value())
+ "' >> .ssh/authorized_keys && chmod 0600 .ssh/authorized_keys";
const SshParameters params = device.sshParameters();