Dropbear compilation installation and service scripting

Source: Internet
Author: User

Compiling the installation

Download Dropbear, and unzip

# wget http://matt.ucc.asn.au/dropbear/releases/dropbear-2015.67.tar.bz2 # tar xvf dropbear-2015.67.tar.bz2# CD dropbear-2015.67#./configure--prefix=/usr/local/dropbear--sysconfdir=/etc/dropbear

Compile and install Dropbear to specify which programs to install Dropbear

# make programs= ' dropbear dbclient dropbearkey dropbearconvert SCP ' # make programs= ' dropbear dbclient dropbearkey Dropbea Rconvert SCP "Install

No/etc/dropbear after installation, and/etc/dropbear/dropbear_dss_host_key and/etc/dropbear/dropbear_rsa_host_key files-T specify type -f Specifies the installation to that

# mkdir/etc/dropbear#/usr/local/dropbear/bin/dropbearkey-t dss-f/etc/dropbear/dropbear_dss_host_key#/usr/local/ Dropbear/bin/dropbearkey-t rsa-s 4096-f/etc/dropbear/dropbear_rsa_host_key

You can now start dropbear

# /usr/local/dropbear/sbin/dropbear -p 2222        # Monitor on 2222 Port # ps aux | grep dropbear        # The service has been started root     25377  0.0  0.0  15300    536 ?        Ss   17:50    0:00 /usr/local/dropbear/sbin/dropbear -p 2222root     25379   0.0  0.0 103256   856 pts/2    S+    17:51   0:00 grep dropbear# netstat -tnlp          #2222端口开始监听Active  Internet connections  (only servers) proto  recv-q send-q local address                foreign address             state        PID/Program name   tcp         0      0 127.0.0.1:8307               0.0.0.0:*                    listen      2861/ vmware-hostd   tcp        0       0 0.0.0.0:2222                 0.0.0.0:*                    LISTEN      25377/dropbear          &nbSp;   tcp        0      0  :::22                        :::*                          LISTEN       2576/sshd                        tcp         0      0 :::2222                      :::*                           listen   &nbsP;  25377/dropbear # ss -tanltate       recv-q  Send-Q                            Local Address:Port                               Peer Address:Port LISTEN       0      100                                           :::2222                                         :::*       listen      0      100                                             *:2222                                          *:*

Change a port

Xshell:\> ssh 192.168.1.9 2222 #可以连接

Do not want to use SSH service, back to the original port

# chkconfig sshd off #默认开机不启动 # service sshd stop

Authoring of service scripts

Want Dropbear to boot, switch to port 2222.

# vim/etc/rc.d/rc.local/usr/local/dropbear/sbin/dropbear-p 2222 #能启动, but can't shut down, write a service script
# vim /etc/sysconfig/dropbear   port=2222# vim /etc/rc.d/init.d/dropbear#!/ bin/bash## chkconfig: 2345 75 50     Default Level      startup level      Shutdown Level # description: lightweight ssh2 implementation#[ -r  /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions[ -f /etc/ Sysconfig/dropbear ] && . /etc/sysconfig/dropbeardsskey=/etc/dropbear/dropbear_dss _host_keyrsakey=/etc/dropbear/dropbear_rsa_host_keypidfile=/var/run/dropbear.pidlockfile=/var/lock/subsys/ dropbeardropbearkey=/usr/local/dropbear/bin/dropbearkeydropbear=/usr/local/dropbear/sbin/dropbearport=${port:= 22}gendsskey ()  {    if [ ! -f  $dsskey  ]; then          $dropbearkey  -t dss -f  $dsskey  &>  /dev/null &nbsP;      [ $? -eq 0 ] && return 0  | |  return 1    RETVAL=$?    if [  $RETVAL  -eq  0 ]; then        echo -n  "Generate dss  key finished. "         passed        echo         return 0    else         echo -n  "Genrate dss key failed"          failure        echo         exit 6    fi    else         return 0    fi}genrsakey ()  {     if [ ! -f  $rsakey  ]; then        $ dropbearkey -t rsa -f  $rsakey  -s 2048 &> /dev/null     #   [ $? -eq 0 ] && return 0 | |  return 1         #这行不需要了     retval=$?     if [  $RETVAL  -eq 0 ]; then         echo -n  "generate rsa key finished."         passed        echo         return 0    else         echo -n  "Genrate rsa key failed"          failure        echo        exit 6     fi    else        return 0     fi}start ()  {    gendsskey    genrsakey          if [ -f  $lockfile  ]; then         echo -n  "dropbear is already running."         failure        echo         exit 7    fi         echo -n  "Start dropbear"     daemon --pidfile   $pidfile   $dropbear  -p  $port     retval=$?    echo          if [  $RETVAL  -eq 0 ];then         touch  $lockfile         return 0    else         rm -f  $lockfile   $pidfile          return 1    fi}stop ()  {    if  [ ! -f  $lockfile  ]; then        echo  -n  "dropbear is not running."         failure        echo         exit 8    fi         echo -n  "Stop dropbear:"     killproc dropbear     retval=$?    echo        [  $RETVAL  -eq 0 ] && rm -f  $lockfile  && return 0 | |  return 1}case $1 in start)     start ;; Stop)     stop;; Restart)     stop     start ;; *)      exit 3 ;; Esac
# service dropbear startstart dropbear                                                [Determine]# service dropbear restartstop dropbear:                                                [Determine]start dropbear                                               [Determine]#  Service dropbear stopstop dropbear:                                               [OK]


This article is from the "three elder brother" blog, please be sure to keep this source http://523958392.blog.51cto.com/9871195/1628158

Dropbear compilation installation and service scripting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.