lxc-sshd.in revision 70e279574cd07e743d1f6e498d569add3fa6a7de
65d8ae9c4a66f5ca85289c02dc06d63261c84619Scott Moser# lxc: linux Container library
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# Daniel Lezcano <daniel.lezcano@free.fr>
acbb59f50d5196facde837ea377f70e98ce1e6f8Serge Hallyn# This library is free software; you can redistribute it and/or
acbb59f50d5196facde837ea377f70e98ce1e6f8Serge Hallyn# modify it under the terms of the GNU Lesser General Public
acbb59f50d5196facde837ea377f70e98ce1e6f8Serge Hallyn# License as published by the Free Software Foundation; either
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# version 2.1 of the License, or (at your option) any later version.
acbb59f50d5196facde837ea377f70e98ce1e6f8Serge Hallyn# This library is distributed in the hope that it will be useful,
acbb59f50d5196facde837ea377f70e98ce1e6f8Serge Hallyn# but WITHOUT ANY WARRANTY; without even the implied warranty of
acbb59f50d5196facde837ea377f70e98ce1e6f8Serge Hallyn# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# Lesser General Public License for more details.
acbb59f50d5196facde837ea377f70e98ce1e6f8Serge Hallyn# You should have received a copy of the GNU Lesser General Public
acbb59f50d5196facde837ea377f70e98ce1e6f8Serge Hallyn# License along with this library; if not, write to the Free Software
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn if [ $? -ne 0 ]; then
4759162d078d86628956cae4846c6efccf548e67Serge Hallynroot:x:0:0:root:/root:/bin/bash
4759162d078d86628956cae4846c6efccf548e67Serge Hallynsshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
4759162d078d86628956cae4846c6efccf548e67Serge Hallynroot:x:0:root
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane Graberssh-keygen -t rsa -f $rootfs/etc/ssh/ssh_host_rsa_key
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallynssh-keygen -t dsa -f $rootfs/etc/ssh/ssh_host_dsa_key
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane Graber # by default setup root password with no password
f02ce27d4b1a9d01b88d0ffaf626e5bafa671bf0Stéphane GraberHostKey /etc/ssh/ssh_host_rsa_key
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberHostKey /etc/ssh/ssh_host_dsa_key
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberUsePrivilegeSeparation yes
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberKeyRegenerationInterval 3600
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberServerKeyBits 768
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberSyslogFacility AUTH
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberLoginGraceTime 120
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberPermitRootLogin yes
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberStrictModes yes
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberRSAAuthentication yes
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberPubkeyAuthentication yes
57d116ab501594c2e50ab45f1cf2fae48c5eab09Serge HallynIgnoreRhosts yes
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge HallynRhostsRSAAuthentication no
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberHostbasedAuthentication no
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberPermitEmptyPasswords yes
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane GraberChallengeResponseAuthentication no
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane Graberlxc.utsname = $name
f2a95ee1bf54c949614a68bf152ea9a8e1d3a172Stéphane Graberlxc.pts = 1024
1aad9e44d65e7c20dabc4c99f57bcf532db66c68Serge Hallynlxc.rootfs = $rootfs
0a3673e80732ab83d807d406fb2fd3c3b7f54ad3Stéphane Graberlxc.mount.entry=/dev $rootfs/dev none ro,bind 0 0
0a3673e80732ab83d807d406fb2fd3c3b7f54ad3Stéphane Graberlxc.mount.entry=/lib $rootfs/lib none ro,bind 0 0
0a3673e80732ab83d807d406fb2fd3c3b7f54ad3Stéphane Graberlxc.mount.entry=/bin $rootfs/bin none ro,bind 0 0
0a3673e80732ab83d807d406fb2fd3c3b7f54ad3Stéphane Graberlxc.mount.entry=/usr /$rootfs/usr none ro,bind 0 0
0a3673e80732ab83d807d406fb2fd3c3b7f54ad3Stéphane Graberlxc.mount.entry=/sbin $rootfs/sbin none ro,bind 0 0
17abf2784de1047fb2904ff130ee5efe4ea7b598Elan Ruusamäelxc.mount.entry=tmpfs $rootfs/var/run/sshd tmpfs mode=0644 0 0
0a3673e80732ab83d807d406fb2fd3c3b7f54ad3Stéphane Graberlxc.mount.entry=@LXCTEMPLATEDIR@/lxc-sshd $rootfs/sbin/init none bind 0 0
0a3673e80732ab83d807d406fb2fd3c3b7f54ad3Stéphane Graberlxc.mount.entry=/lib64 $rootfs/lib64 none ro,bind 0 0
42ff5f0f8767114d060f5031055038a1a1c3759aSerge Hallyn$1 -h|--help -p|--path=<path>
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallynoptions=$(getopt -o hp:n: -l help,path:,name: -- "$@")
4759162d078d86628956cae4846c6efccf548e67Serge Hallyn --) shift 1; break ;;
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn echo "This script should be run as 'root'"
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn echo "'lxc-init is not accessible on the system"
65d8ae9c4a66f5ca85289c02dc06d63261c84619Scott Moser echo "'sshd' is not accessible on the system "
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallynif [ -z "$path" ]; then
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn echo "'path' parameter is required"
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn echo "failed to install sshd's rootfs"
8a63c0a9d9089e6365e5a696455476febed39d6aStéphane Graber echo "failed to configure sshd template"
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn echo "failed to write configuration file"