77 lines
2.1 KiB
Bash
Executable File
77 lines
2.1 KiB
Bash
Executable File
#!/bin/bash -
|
|
#
|
|
#===================================================================================
|
|
#
|
|
# Copyright Beijing Linx Technology Co., Ltd. 2010年09月21日
|
|
#
|
|
# Filename: conf_sshd
|
|
#
|
|
# USAGE: conf_sshd [interface]
|
|
#
|
|
# Description: configure sshd,to achieve remote installation
|
|
#
|
|
# Version: 0.1
|
|
# Created: 2010年09月21日
|
|
#
|
|
# Author: Hu Gang
|
|
#
|
|
# ChangeLog: 1. 2010年09月21日 Create.
|
|
#
|
|
#===================================================================================
|
|
#
|
|
|
|
#===================================================================================
|
|
#Set variables
|
|
#===================================================================================
|
|
interface=
|
|
filepath=/etc/sysconfig/network-devices
|
|
#===================================================================================
|
|
#Performance function
|
|
#===================================================================================
|
|
|
|
usage(){
|
|
echo "$0 [interface]"
|
|
echo "The name of the interface. This is usually a driver name followed "
|
|
echo "by a unit number, for example eth0 for the first Ethernet interface."
|
|
echo "default interface is eth0"
|
|
}
|
|
|
|
startnetwork(){
|
|
cp ${filepath}/{ifcfg.template,ifcfg-${interface}}
|
|
echo 'enter your IP:'
|
|
read ip
|
|
echo 'enter your netmask:'
|
|
read netmask
|
|
echo 'enter your gateway:'
|
|
read gateway
|
|
sed -i "s%IPADDR=.*%IPADDR=${ip}%g" ${filepath}/ifcfg-${interface}
|
|
sed -i "s%NETMASK=.*%NETMASK=${netmask}%g" ${filepath}/ifcfg-${interface}
|
|
sed -i "s%GATEWAY=.*%GATEWAY=${gateway}%g" ${filepath}/ifcfg-${interface}
|
|
ifup ${interface}
|
|
}
|
|
|
|
startsshd(){
|
|
sed -i "s%^#shm%shm%g" /etc/fstab
|
|
mount -a
|
|
mkdir -p /var/empty
|
|
openssh-keygen
|
|
/usr/sbin/sshd -o X11Forwarding=yes
|
|
}
|
|
|
|
#===================================================================================
|
|
#Execution
|
|
#===================================================================================
|
|
# the interface between the eth0 to eth9
|
|
if [ $# -eq 0 ]; then
|
|
interface=eth0
|
|
elif [[ V$1 == Veth[0-9] ]]; then
|
|
interface="$1"
|
|
else
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
startnetwork
|
|
startsshd
|
|
|