Public bug reported:

I've modified /usr/bin/ssh-import-id to show a stack trace rather than 
unhelpful message:
 TypeError: join() argument must be str or bytes, not 'NoneType'

Then, running:
$ env -u HOME ssh-import-id smoser
Traceback (most recent call last):
  File "/usr/bin/ssh-import-id", line 62, in <module>
    main()
  File "/usr/bin/ssh-import-id", line 45, in main
    k = import_keys(proto, username, parser.options.useragent)
  File "/usr/lib/python3/dist-packages/ssh_import_id/__init__.py", line 204, in 
import_keys
    local_keys = key_list(read_keyfile())
  File "/usr/lib/python3/dist-packages/ssh_import_id/__init__.py", line 135, in 
read_keyfile
    output_file = parser.options.output or os.path.join(os.getenv("HOME"), 
".ssh", "authorized_keys")
  File "/usr/lib/python3.5/posixpath.py", line 89, in join
    genericpath._check_arg_types('join', a, *p)
  File "/usr/lib/python3.5/genericpath.py", line 143, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'

I came to find this by trying to  launch an instance with:

$ ec2metadata --user-data
#!/bin/sh
exec >/my.log 2>&1
cat /proc/uptime
date -R
ssh-import-id smoser

The basic issue is that the environment that cloud-init runs in does not
have HOME set.

I suggest using os.path.expanduser
def authorized_key_file():
        return os.path.join(os.path.expanduser("~"), ".ssh", "authorized_keys")

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: ssh-import-id 5.5-0ubuntu1 [modified: usr/bin/ssh-import-id]
ProcVersionSignature: User Name 4.4.0-18.34-generic 4.4.6
Uname: Linux 4.4.0-18-generic x86_64
ApportVersion: 2.20.1-0ubuntu1
Architecture: amd64
Date: Fri Apr 15 17:36:09 2016
Ec2AMI: ami-929f8cf8
Ec2AMIManifest: 
ubuntu-us-east-1/images-testing/hvm-instance/ubuntu-xenial-daily-amd64-server-20160412.manifest.xml
Ec2AvailabilityZone: us-east-1c
Ec2InstanceType: m3.medium
Ec2Kernel: unavailable
Ec2Ramdisk: unavailable
PackageArchitecture: all
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: ssh-import-id
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: ssh-import-id (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug ec2-images xenial

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1570997

Title:
  fail if HOME environment variable is not set

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ssh-import-id/+bug/1570997/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to