From cd17d790673229ca0dfa42666a1800916a987578 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Thu, 24 Feb 2022 16:13:47 +0000 Subject: [PATCH] ssh: Advise use of 'balena login' if root authentication fails Change-type: patch --- lib/utils/ssh.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/utils/ssh.ts b/lib/utils/ssh.ts index 5782da4b..0f005050 100644 --- a/lib/utils/ssh.ts +++ b/lib/utils/ssh.ts @@ -299,7 +299,13 @@ export const findBestUsernameForDevice = _.memoize( const { getCachedUsername } = await import('./bootstrap'); username = (await getCachedUsername())?.username; } - return username || 'root'; + if (!username) { + const { stripIndent } = await import('./lazy'); + throw new ExpectedError(stripIndent` + SSH authentication failed for 'root@${hostname}'. + Please login with 'balena login' for alternative authentication.`); + } + return username; }, );