Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
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.
DescriptionAleksandar 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 6Aleksandar 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.
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 10Aleksandar 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 11Aleksandar Kostadinov
2020-06-30 23:09:57 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