Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1746700

Summary: ssh plugin fails if authorized_keys has non-ascii utf-8 text
Product: [oVirt] otopi Reporter: Yedidyah Bar David <didi>
Component: Plugins.networkAssignee: Yedidyah Bar David <didi>
Status: CLOSED CURRENTRELEASE QA Contact: Guilherme Santos <gdeolive>
Severity: medium Docs Contact:
Priority: low    
Version: masterCC: bugs, lleistne, rdlugyhe
Target Milestone: ovirt-4.4.0Flags: sbonazzo: ovirt-4.4?
Target Release: 1.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: otopi-1.9.0 Doc Type: Bug Fix
Doc Text:
The ovirt-host-deploy package uses otopi. Previously, otopi could not handle non-ASCII text in /root/.ssh/authorized_keys and failed with an error: 'ascii' codec can't decode byte 0xc3 in position 25: ordinal not in range(128). The new release fixes this issue by adding support for Unicode characters to otopi.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-20 19:59:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Integration RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1700864    

Description Yedidyah Bar David 2019-08-29 06:54:25 UTC
Description of problem:

If /root/.ssh/authorized_keys has non-ascii text, and otopi is directed to add a key to this file (which is normal during adding a host to an oVirt engine), otopi (ovirt-host-deploy) fails with:

[ ERROR ] Failed to execute stage 'Misc configuration': 'ascii' codec can't decode byte 0xc3 in position 25: ordinal not in range(128)

And the log file has something like:

2019-08-29 09:43:59,896+0300 DEBUG otopi.context context._executeMethod:127 Stage misc METHOD otopi.plugins.otopi.network.ssh.Plugin._append_key
/usr/share/otopi/plugins/otopi/network/ssh.py:96: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  keymatch.group('alias') == linematch.group('alias')
2019-08-29 09:43:59,896+0300 DEBUG otopi.context context._executeMethod:145 method exception
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/otopi/context.py", line 132, in _executeMethod
    method['method']()
  File "/usr/share/otopi/plugins/otopi/network/ssh.py", line 152, in _append_key
    constants.CoreEnv.MODIFIED_FILES
  File "/usr/lib/python2.7/site-packages/otopi/filetransaction.py", line 144, in __init__
    self._content = u'\n'.join([common.toUStr(i) for i in content])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 413: ordinal not in range(128)
2019-08-29 09:43:59,897+0300 ERROR otopi.context context._executeMethod:154 Failed to execute stage 'Misc configuration': 'ascii' codec can't decode byte 0xc3 in position 413: ordinal not in range(128)

Version-Release number of selected component (if applicable):

Reproduced on current master, probably forever.

How reproducible:
Always

Steps to Reproduce:
1. echo "ssh-rsa FakeRSAKey1 test-À" >> ~/.ssh/authorized_keys
2. otopi NETWORK/sshEnable=bool:True 'NETWORK/sshKey=str:"ssh-rsa FakeRSAKey ovirt-engine"' 'NETWORK/sshUser=str:root'
3.

Actual results:

Fails as above

Expected results:

Succeeds

Additional info:

This was reported in:

https://lists.ovirt.org/archives/list/users@ovirt.org/thread/2A4Q3MTNXQVXIKK36LPJOBGRWMZ3SCXO/

Comment 1 Yedidyah Bar David 2019-08-29 07:06:17 UTC
Workaround: Edit your authorized_keys and remove/replace the offending text. It should only be contained in the comment field (the last one in each line), which is safe to edit. The actual key and options/type fields should be ascii only anyway.

Comment 2 Guilherme Santos 2020-01-03 20:13:07 UTC
Verified on:
otopi-common-1.9.0-1.el8ev.noarch

Steps:
1. ssh on target host 
2. # echo "ssh-rsa FakeRSAKey1 test-À" >> ~/.ssh/authorized_keys
3. On engine, go to Hosts (Compute -> Hosts) and put the target host in maintenance mode (Management -> Maintenance) 
4. Reinstall host (Installation -> Reinstall)

Results:
Installation completed successfully

Comment 5 Sandro Bonazzola 2020-05-20 19:59:53 UTC
This bugzilla is included in oVirt 4.4.0 release, published on May 20th 2020.

Since the problem described in this bug report should be
resolved in oVirt 4.4.0 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.