diff --git a/apps/dokploy/server/wss/terminal.ts b/apps/dokploy/server/wss/terminal.ts index 87b096c07..9dafba22f 100644 --- a/apps/dokploy/server/wss/terminal.ts +++ b/apps/dokploy/server/wss/terminal.ts @@ -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; } diff --git a/apps/dokploy/server/wss/utils.ts b/apps/dokploy/server/wss/utils.ts index e98e50169..cd50130ca 100644 --- a/apps/dokploy/server/wss/utils.ts +++ b/apps/dokploy/server/wss/utils.ts @@ -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);