Skip to content

Commit

Permalink
Add --sshkey to kickstart sshpw command (#1274104)
Browse files Browse the repository at this point in the history
This allows users to setup installation users with ssh keys instead of
passwords.

Resolves: rhbz#1274104
  • Loading branch information
bcl committed Nov 7, 2015
1 parent 6f7b160 commit 36f980a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion anaconda.spec.in
Expand Up @@ -21,7 +21,7 @@ Source0: %{name}-%{version}.tar.bz2
# Also update in AM_GNU_GETTEXT_VERSION in configure.ac
%define gettextver 0.18.3
%define intltoolver 0.31.2-3
%define pykickstartver 2.9
%define pykickstartver 2.20
%define dnfver 0.6.4
%define partedver 1.8.1
%define pypartedver 2.5-2
Expand Down
12 changes: 9 additions & 3 deletions utils/handle-sshpw
Expand Up @@ -3,7 +3,7 @@
# handle-sshpw: Code processing sshpw lines in kickstart files for the
# install environment.
#
# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
# Copyright (C) 2012-2015 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -46,9 +46,15 @@ u = users.Users()
userdata = ksparser.handler.sshpw.dataList()
for ud in userdata:
if u.checkUserExists(ud.username, root="/"):
u.setUserPassword(username=ud.username, password=ud.password,
isCrypted=ud.isCrypted, lock=ud.lock)
if not ud.sshkey:
u.setUserPassword(username=ud.username, password=ud.password,
isCrypted=ud.isCrypted, lock=ud.lock)
else:
kwargs = ud.__dict__
kwargs.update({"root": "/"})
u.createUser(ud.username, **kwargs)

if ud.sshkey:
# Setup the account so that only the sshkey can be used
u.setUserPassword(username=ud.username, password="*", isCrypted=True, lock=False)
u.setUserSshKey(username=ud.username, key=ud.password, root="/")

0 comments on commit 36f980a

Please sign in to comment.