From 6e1499f31dfa46e5c0aa13b36463506c1d7e5b91 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Wed, 25 Jun 2014 02:08:05 +0200 Subject: [PATCH] Create empty authorized_keys --- chroot-ssh.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chroot-ssh.sh b/chroot-ssh.sh index 5888dec..0c1bf22 100644 --- a/chroot-ssh.sh +++ b/chroot-ssh.sh @@ -156,7 +156,7 @@ echo -n "1 - Creating the chroot..." mkdir -p $chrootdir/lib/{x86_64-linux-gnu,tls/i686/cmov,i686/cmov} mkdir -p $chrootdir/usr/{bin,lib,sbin} mkdir -p $chrootdir/usr/lib/{x86_64-linux-gnu,openssh,i686/cmov} - mkdir -p $chrootdir/root/.ssh + mkdir -p $chrootdir/root/.ssh && chmod 700 $chrootdir/root/.ssh mkdir -p $chrootdir/var/{log,run/sshd} touch $chrootdir/var/log/{authlog,lastlog,messages,syslog} touch $chrootdir/etc/fstab @@ -185,8 +185,8 @@ echo -n "4 - Configuring the chroot..." [ -n "$port" ] && [ "$port" != "guess" ] && sed -i "s/^Port 2222/Port ${port}/" ${jail}/etc/ssh/sshd_config [ -n "$ip" ] && sed -i "s/IP/$ip/g" ${jail}/etc/ssh/sshd_config - [ -n "$pub_key_path" ] && cat $pub_key_path > ${jail}/root/.ssh/authorized_keys \ - && chmod -R 600 ${jail}/root/.ssh/ && chown -R root:root ${jail}/root/.ssh/ + touch ${jail}/root/.ssh/authorized_keys && chmod 600 ${jail}/root/.ssh/authorized_keys && chown -R root:root ${jail}/root/.ssh/ + [ -n "$pub_key_path" ] && cat $pub_key_path >> ${jail}/root/.ssh/authorized_keys echo "...OK"