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:
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: ssh-import- id", line 62, in <module> ssh-import- id", line 45, in main options. useragent) python3/ dist-packages/ ssh_import_ id/__init_ _.py", line 204, in import_keys read_keyfile( )) python3/ dist-packages/ ssh_import_ id/__init_ _.py", line 135, in read_keyfile options. output or os.path. join(os. getenv( "HOME") , ".ssh", "authorized_keys") python3. 5/posixpath. py", line 89, in join ._check_ arg_types( 'join', a, *p) python3. 5/genericpath. py", line 143, in _check_arg_types _.__name_ _)) from None
$ env -u HOME ssh-import-id smoser
Traceback (most recent call last):
File "/usr/bin/
main()
File "/usr/bin/
k = import_keys(proto, username, parser.
File "/usr/lib/
local_keys = key_list(
File "/usr/lib/
output_file = parser.
File "/usr/lib/
genericpath
File "/usr/lib/
(funcname, s.__class_
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 key_file( ): join(os. path.expanduser ("~"), ".ssh", "authorized_keys")
def authorized_
return os.path.
ProblemType: Bug ssh-import- id] ature: User Name 4.4.0-18.34-generic 4.4.6 us-east- 1/images- testing/ hvm-instance/ ubuntu- xenial- daily-amd64- server- 20160412. manifest. xml Zone: us-east-1c ture: all 256color DIR=<set>
DistroRelease: Ubuntu 16.04
Package: ssh-import-id 5.5-0ubuntu1 [modified: usr/bin/
ProcVersionSign
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-
Ec2Availability
Ec2InstanceType: m3.medium
Ec2Kernel: unavailable
Ec2Ramdisk: unavailable
PackageArchitec
ProcEnviron:
TERM=xterm-
PATH=(custom, no user)
XDG_RUNTIME_
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: ssh-import-id
UpgradeStatus: No upgrade log present (probably fresh install)