From e161059a18173e2b61c54dba9eab774401fb5f1f Mon Sep 17 00:00:00 2001 From: Eduardo Otubo Date: Wed, 15 Jul 2020 20:21:02 +0200 Subject: ssh exit with non-zero status on disabled user (#472) It is confusing for scripts, where a disabled user has been specified, that ssh exits with a zero status by default without indication anything failed. I think exitting with a non-zero status would make more clear in scripts and automated setups where things failed, thus making noticing the issue and debugging easier. Signed-off-by: Eduardo Otubo Signed-off-by: Aleksandar Kostadinov LP: #1170059 --- cloudinit/ssh_util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cloudinit') diff --git a/cloudinit/ssh_util.py b/cloudinit/ssh_util.py index 72e4e65e..89150acf 100644 --- a/cloudinit/ssh_util.py +++ b/cloudinit/ssh_util.py @@ -40,11 +40,13 @@ VALID_KEY_TYPES = ( "ssh-rsa-cert-v01@openssh.com", ) +_DISABLE_USER_SSH_EXIT = 142 DISABLE_USER_OPTS = ( "no-port-forwarding,no-agent-forwarding," "no-X11-forwarding,command=\"echo \'Please login as the user \\\"$USER\\\"" - " rather than the user \\\"$DISABLE_USER\\\".\';echo;sleep 10\"") + " rather than the user \\\"$DISABLE_USER\\\".\';echo;sleep 10;" + "exit " + str(_DISABLE_USER_SSH_EXIT) + "\"") class AuthKeyLine(object): -- cgit v1.2.3