home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
root
/
sbin
/
inst_setup_ssh
< prev
next >
Wrap
Text File
|
2006-11-29
|
3KB
|
107 lines
# will be sourced by /sbin/inst_setup
# vim: syntax=sh
if [ -z "$INSTSYS" ] ; then
echo "variable INSTSYS not set"
sleep 1
exit 1
fi
#
nosshkey=false
if [ "$1" = "-n" ] ; then
nosshkey=true
shift
fi
#
if grep -qwi nosshkey < /proc/cmdline ; then
nosshkey=true
fi
#
if ! test -z "$1" ; then
sshpassword=$1
fi
echo 'sshd found, prepare remote login'
if test -L /root ; then rm -f /root ; fi
if test -L /etc/ssh ; then rm -f /etc/ssh ; fi
mkdir -p /etc/ssh /root
cp -a --remove-destination $INSTSYS/root/.bash_login /root
cp -a --remove-destination $INSTSYS/root/.bash_history /root
cp -a --remove-destination $INSTSYS/root/.vimrc /root
cp -a --remove-destination $INSTSYS/etc/ssh/{moduli,primes,ssh*config*} /etc/ssh
# not needed in initrd
grep -vi UsePrivilegeSeparation < $INSTSYS/etc/ssh/sshd_config > /etc/ssh/sshd_config
echo UsePrivilegeSeparation no >> /etc/ssh/sshd_config
#
if test ! -z "$nameserver" ; then
echo "nameserver $nameserver" >> /etc/resolv.conf
fi
if test ! -z "$domain" ; then
echo "search $domain" >> /etc/resolv.conf
fi
mkdir -p /dev/pts
mkdir -p /dev/shm
grep -q devpts /proc/mounts || \
mount -n -t devpts -o mode=0620,gid=5 devpts /dev/pts
#
if [ "$nosshkey" = "true" ] ; then
# for inst-sys testing
echo using built-in ssh keys
cp -a --remove-destination $INSTSYS/etc/ssh/*key* /etc/ssh/
else
#
echo "generating SSH keys ... "
#
if ! test -f /etc/ssh/ssh_host_key ; then
echo Generating /etc/ssh/ssh_host_key.
ssh-keygen -t rsa1 -b 1024 -f /etc/ssh/ssh_host_key -N ''
fi
if ! test -f /etc/ssh/ssh_host_dsa_key ; then
echo Generating /etc/ssh/ssh_host_dsa_key.
ssh-keygen -t dsa -b 1024 -f /etc/ssh/ssh_host_dsa_key -N ''
fi
if ! test -f /etc/ssh/ssh_host_rsa_key ; then
echo Generating /etc/ssh/ssh_host_rsa_key.
ssh-keygen -t rsa -b 1024 -f /etc/ssh/ssh_host_rsa_key -N ''
fi
fi
if [ ! -z "$sshpassword" ] ; then
mv -f /etc/passwd /etc/passwd.
mv -f /etc/shadow /etc/shadow.
cat /etc/passwd. > /etc/passwd
cat /etc/shadow. > /etc/shadow
echo "setting root pwd to '$sshpassword'"
echo "root:$sshpassword" | chpasswd
fi
chmod -R og-rxw /etc/ssh /root /etc/shadow 2>/dev/null
chown -R 0.0 /etc/ssh /root /etc/shadow 2>/dev/null
echo "Starting SSH daemon ... "
#
/usr/sbin/sshd || {
export SSH_FAILED=true
export YAST2_SSH=false
echo 'sshd did NOT start!'
}
if [ ! "$SSH_FAILED" ] ; then
echo
ip -oneline -family inet link show up | \
sed -n '/link\/\(ether\|ieee1394\|tr\)/s@^[^ ]\+[ ]\+\([^:]\+\).*@\1@p' | \
xargs --no-run-if-empty -n1 ip addr show dev | \
sed 's@^[0-9]\+: *@@'
export YAST2_SSH=true
cat <<EOF
*** sshd has been started ***
EOF
fi
[ -f /proc/splash ] && echo verbose >/proc/splash