zoukankan      html  css  js  c++  java
  • dropbear启动脚本

    #!/bin/bash
    # chkconfig: 2345 75 50 默认级别 启动级别 关闭级别
    # description: dropbear ssh daemon
    dsskey=/etc/dropbear/dropbear_dss_host_key
    rsakey=/etc/dropbear/dropbear_rsa_host_key
    pidfile=/var/run/dropbear.pid
    lockfile=/var/lock/subsys/dropbear
    dropbearkey=/usr/local/bin/dropbearkey
    dropbear=/usr/local/sbin/dropbear

    [ -r /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions
    [ -f /etc/sysconfig/dropbear ] && . /etc/sysconfig/dropbear
    keysize=${keysize:-2048}
    port=${port:-22}

    gendsskey() {
    [ -d /etc/dropbear ] || mkdir /etc/dropbear
    echo -n "Starting generate the dss key:"
    $dropbearkey -t dss -f $dsskey &>/dev/null
    RETVAL=$?
    if [ $RETVAL -eq 0 ] ; then
    success
    echo
    return 0
    else
    failure
    echo
    return 1
    fi
    }

    start () {
    [ -e $deskey ] || gendsskey
    [ -e Srsakey ] || genrsakey
    if [ -e $lockfile ] ; then
    echo -n "dropbear daemon is already running"
    success
    echo
    exit 0
    fi
    echo -n "Starting dropbear: "
    daemon --pidfile="$pidfile" $dropbear -p $port -d $dsskey -r $rsakey
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ] ; then
    touch $lockfile
    return 0
    else
    rm -f $lockfile $pidfile
    return 1
    fi
    }

    stop () {
    if [ ! -e $lockfile ] ; then
    echo -n "bear service is stopped:"
    success
    exit 1
    fi
    echo -n "Stopping dropbear daemon:"
    killproc dropbear
    RETVAL=$?
    echo

    if [ $RETVAL -eq 0 ] ; then
    rm -f $lockfile $pidfile
    return 0
    else
    return 1
    fi
    }
    status () {
    if [ -e $lockfile ] ; then
    echo "dropbear is running."
    else
    echo "dropbear is stopped"
    fi
    }
    usage () {
    echo "Usage:dropbear {start|stop|restart|status|gendsskey|genrsakey}"
    }

    case $1 in
    start)
    start ;;
    stop)
    stop ;;
    restart)
    stop
    start ;;
    status)
    status ;;
    gendsskey)
    gendsskey ;;
    genrsakey)
    genrsakey ;;
    *)
    usage ;;
    esac

  • 相关阅读:
    取石子(二)巴仕博弈+尼姆博弈
    hdu2430Beans(单调队列)
    LCD: 2D-3D匹配算法
    如何选择视觉CV光源颜色
    gpgpu-sim卡分配程序设计实例分析
    PointRCNN: 点云的3D目标生成与检测
    3D点云重建原理及Pytorch实现
    GPU加速计算
    红外传感器技术
    Linux架构思维导图
  • 原文地址:https://www.cnblogs.com/bpsanshao/p/11283380.html
Copyright © 2011-2022 走看看