Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Dropbear compilation, installation and service scripting

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Compilation and installation

Download dropbear and extract it

# 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

To compile and install dropbear, specify which programs to install dropbear

# make PROGRAMS= "dropbear dbclient dropbearkey dropbearconvert scp" # make PROGRAMS= "dropbear dbclient dropbearkey dropbearconvert scp" install

There is no / etc/dropbear after the installation, and the / etc/dropbear/dropbear_dss_host_key and / etc/dropbear/dropbear_rsa_host_key files-t specify the type-f to be installed there

# 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 # listening on port 2222 # ps aux | the grep dropbear # service has started root 25377 0.0 15300 536? Ss 17:50 0:00 / usr/local/dropbear/sbin/dropbear-p 2222root 25379 0.0 103256 856 pts/2 S+ 17:51 0:00 grep dropbear# netstat-tnlp # 2222 port starts listening to Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 00 127.0.0.1 : 8307 0.0.0.0 LISTEN 2861/vmware-hostd tcp * LISTEN 25377/dropbear tcp 0:: 22:: * LISTEN 2576/sshd tcp 0 0: 2222: * LISTEN 25377/dropbear # ss-tanltate Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 100: 2222: * LISTEN 0 100 *: 2222 *: *

Change to another port

Xshell:\ > ssh 192.168.1.9 2222 # can be connected

Do not want to use ssh service, go back to the original port

# chkconfig sshd off # default boot does not start # service sshd stop

The writing of service script

If you want dropbear to boot, switch to port 2222.

# vim / etc/rc.d/rc.local/usr/local/dropbear/sbin/dropbear-p 222boot can be started, but cannot be shut down. Write a service script # vim / etc/sysconfig/dropbear port=2222# vim / ETC _ etc/rc.d/init.d/functions _ init. D _ init. D _ bind _ blank _ init. Chkconfig: 2345 75 50 default level startup level off level # description: lightweight ssh3 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 [$?-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 # this line does not need RETVAL=$? If [$RETVAL-eq 0]; then echo-n "Generate rsa key finished." Passed echo return 0 else echo-n "Genrate rsakey 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 [OK] # service dropbear restartStop dropbear: [OK] Start dropbear [OK] # service dropbear stopStop dropbear: [OK]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report