feat: add permission grant command when key generation fails

This commit is contained in:
UndefinedPony
2025-01-06 12:09:54 +01:00
parent 76c6d02566
commit 41a970c526
2 changed files with 17 additions and 8 deletions

View File

@@ -20,6 +20,12 @@ const COMMAND_TO_ALLOW_LOCAL_ACCESS = `
echo "✓ Dokploy SSH key added successfully. Reopen the terminal in Dokploy to reconnect."
# ----------------------------------------`;
const COMMAND_TO_GRANT_PERMISSION_ACCESS = `
# ----------------------------------------
sudo chown -R $USER:$USER /etc/dokploy/ssh
# ----------------------------------------
`;
export const getPublicIpWithFallback = async () => {
// @ts-ignore
let ip = null;
@@ -105,7 +111,17 @@ export const setupTerminalWebSocketServer = (
};
} catch (error) {
console.error(`Error setting up private SSH key: ${error}`);
ws.send(`Error setting up private SSH key: ${error}`);
ws.send(`Error setting up private SSH key: ${error}\n`);
if (
error instanceof Error &&
error.message.includes("Permission denied")
) {
ws.send(
`Please run the following command on your server to grant permission access and then reopen this window to reconnect:${COMMAND_TO_GRANT_PERMISSION_ACCESS}`,
);
}
ws.close();
return;
}

View File

@@ -15,13 +15,6 @@ export const getShell = () => {
};
/** Returns private SSH key for dokploy local server terminal. Uses already created SSH key or generates a new SSH key.
*
* In case of permission failures when running locally, run the command below:
```
sudo chown -R $USER:$USER /etc/dokploy/ssh
```
*/
export const setupLocalServerSSHKey = async () => {
const { SSH_PATH } = paths(true);