RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1615842 - using root user error should cause a non-zero exit code
Summary: using root user error should cause a non-zero exit code
Keywords:
Status: CLOSED DUPLICATE of bug 1833874
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: cloud-init
Version: 8.3
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: rc
: 8.3
Assignee: Virtualization Maintenance
QA Contact: Huijuan Zhao
URL:
Whiteboard:
Depends On:
Blocks: 1833874
TreeView+ depends on / blocked
 
Reported: 2018-08-14 11:32 UTC by Aleksandar Kostadinov
Modified: 2024-11-20 07:53 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1833874 (view as bug list)
Environment:
Last Closed: 2020-08-27 14:03:22 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-52170 0 None None None 2021-12-07 03:34:46 UTC

Description Aleksandar Kostadinov 2018-08-14 11:32:29 UTC
Description of problem:

When connecting to host via SSH and the `root` user, by default an error is shown to user. But exit status of that error is `0` instead of something else. This makes situation not ideal to catch in scripts. Script fails at some later point which is harder to debug especially for users of the script (not the script author).

Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux Server release 7.5 (Maipo)
cloud-init-0.7.9-24.el7_5.1.x86_64

How reproducible:
always

Steps to reproduce:

> ssh root@my-cloud-machine
> Please login as the user "cloud-user" rather than the user "root".
> echo $?
> 0

Actual results:

> echo $?
> 0

Expected results:

> echo $?
> 1

Comment 6 Aleksandar Kostadinov 2019-01-10 12:23:11 UTC
I just tested that in 7.6 images (RHEL-7.6-20190103.n.3-Server-x86_64 ) it is still the same.

The issue is that in /root/.ssh/authorizer_keys there is:

> no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"cloud-user\" rather than the user \"root\".';echo;sleep 10" <public key>

At the end there should be something like `exit 1` so that it is clear to a script that something went wrong.

Comment 7 Huijuan Zhao 2020-03-13 07:45:36 UTC
Tested with cloud-init-18.5-6.el7.x86_64 in rhel-7.8, the issue is still there, same as comment 0 and 6.

Comment 10 Aleksandar Kostadinov 2020-06-30 22:38:50 UTC
This should be an easy to fix. Just add `exit 1` as last command in authorized_keys.

i.e. change /root/.ssh/authorized_keys to:

> no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"cloud-user\" rather than the user \"root\".';echo;sleep 10; exit 1" ssh-rsa AA..whatever-private-key....

This worked for me on RHEL 7.6.

Can't such a simple and straightforward fix be applied to 7.x?

Comment 11 Aleksandar Kostadinov 2020-06-30 23:09:57 UTC
Submitted upstream pull request... unless I am mistaken where upstream is.

https://github.com/canonical/cloud-init/pull/469

Comment 12 Eduardo Otubo 2020-07-02 12:13:52 UTC
(In reply to Aleksandar Kostadinov from comment #11)
> Submitted upstream pull request... unless I am mistaken where upstream is.
> 
> https://github.com/canonical/cloud-init/pull/469

Hi Aleksandar,

I see your PR didn't get through because of CLA. I created a new PR since I've already signed it.
Should be quick, once it lands I'll backport it.

Also added your name for credit as original author:
https://github.com/canonical/cloud-init/pull/472

Comment 14 Eduardo Otubo 2020-07-10 08:16:52 UTC
Quick update: The PR was approved and will be merged soon.


Note You need to log in before you can comment on or make changes to this bug.