summaryrefslogtreecommitdiff
path: root/distrib/miniroot
diff options
context:
space:
mode:
authorAlexander Hall <halex@cvs.openbsd.org>2013-12-01 01:54:24 +0000
committerAlexander Hall <halex@cvs.openbsd.org>2013-12-01 01:54:24 +0000
commit559c71ef432a77242249c6a2619ba29b15b8b8a9 (patch)
tree0848cd5948b3974714ad9e130613752a87553126 /distrib/miniroot
parent04cf7e9e8ddba9f5e688c2974ae3e525e18d7795 (diff)
Allows the autoinstaller to pass a public ssh key for inclusion in the
user's .ssh/authorized_keys. Deliberately not in interactive mode since I am not sure it's worth adding another question that only quite few people would enjoy. ok rpe@
Diffstat (limited to 'distrib/miniroot')
-rw-r--r--distrib/miniroot/install.sh16
-rw-r--r--distrib/miniroot/install.sub6
2 files changed, 16 insertions, 6 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh
index 4ac5bfe0872..aa20bfc18bb 100644
--- a/distrib/miniroot/install.sh
+++ b/distrib/miniroot/install.sh
@@ -1,5 +1,5 @@
#!/bin/ksh
-# $OpenBSD: install.sh,v 1.236 2013/11/19 22:20:06 halex Exp $
+# $OpenBSD: install.sh,v 1.237 2013/12/01 01:54:23 halex Exp $
# $NetBSD: install.sh,v 1.5.2.8 1996/08/27 18:15:05 gwr Exp $
#
# Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback
@@ -284,20 +284,26 @@ apply
if [[ -n $user ]]; then
_encr=$(encr_pwd "$userpass")
- uline="${user}:${_encr}:1000:1000:staff:0:0:${username}:/home/${user}:/bin/ksh"
+ _home=/home/$user
+ uline="${user}:${_encr}:1000:1000:staff:0:0:${username}:$_home:/bin/ksh"
echo "$uline" >> /mnt/etc/master.passwd
echo "${user}:*:1000:" >> /mnt/etc/group
echo ${user} > /mnt/root/.forward
- mkdir -p /mnt/home/$user
- (cd /mnt/etc/skel; cp -pR . /mnt/home/$user)
+ _home=/mnt$_home
+ mkdir -p $_home
+ (cd /mnt/etc/skel; cp -pR . $_home)
(umask 077 &&
sed "s,^To: root\$,To: ${username} <${user}>," \
/mnt/var/mail/root > /mnt/var/mail/$user )
- chown -R 1000:1000 /mnt/home/$user /mnt/var/mail/$user
+ chown -R 1000:1000 $_home /mnt/var/mail/$user
echo "1,s@wheel:.:0:root\$@wheel:\*:0:root,${user}@
w
q" | ed /mnt/etc/group 2>/dev/null
+
+ # Add public ssh key to authorized_keys
+ [[ -n "$userkey" ]] &&
+ print -r -- "$userkey" >> $_home/.ssh/authorized_keys
fi
if [[ -n "$_rootpass" ]]; then
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index 1f2f261341d..78674a3a548 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.707 2013/11/29 22:28:12 rpe Exp $
+# $OpenBSD: install.sub,v 1.708 2013/12/01 01:54:23 halex Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback
@@ -380,6 +380,10 @@ user_setup() {
askpassword $user
userpass=$_password
+ userkey=
+ _autorespond "Public ssh key for $user" none &&
+ [[ $resp != none ]] && userkey=$resp
+
if [[ $sshd == y ]]; then
ask_yn "Since you set up a user, disable sshd(8) logins to root?" yes
sshd_disableroot=$resp