首页 > 系统服务 > 详细

linux下openssh临时替代工具----dropbear

时间:2014-03-26 08:14:31      阅读:658      评论:0      收藏:0      [点我收藏+]

     在linux下,通常使用openssh来进行远程链接,但是如果要重新安装openssh的话,dropbear是一个很好的替代品

     Dropbear是一个相对较小的SSH服务器和客户端。它运行在一个基于POSIX的各种平台. Dropbear是开源软件,在麻省理工学院式的许可证。 Dropbear是特别有用的“嵌入”式的Linux(或其他Unix)系统

    下载dropbear:https://matt.ucc.asn.au/dropbear/下直接下载即可

    开始编译安装吧

   bubuko.com,布布扣

  在dropbear下

    dropbear------->sshd 服务器端

    dbclient--------->ssh 客户端

bubuko.com,布布扣

bubuko.com,布布扣

没有报错,说明编译环境ok的--------gcc是必须要装的

bubuko.com,布布扣

bubuko.com,布布扣

install一安装就ok了

bubuko.com,布布扣

dropbear只支持SSH2的加密方式,即只有dss和rsa两种密钥设定,但是在install的时候dropbear没有创建/etc/dropbear主配文件需要自己建立

bubuko.com,布布扣

在这个目录下创建这俩个密钥

bubuko.com,布布扣

开始制定密钥文件,先设置export环境变量

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

在/etc/dropbear下生成文件

现在就可以开始服务了

bubuko.com,布布扣

bubuko.com,布布扣

 

开始服务后,就可以对本机的openssh进行关闭操作了,链接依然可以通过dropbear保持链接

bubuko.com,布布扣

关闭后链接依旧保持着链接,就可以重新远程安装openssh了

编写一个sys启动脚本

#/bin/bash
#chkconfig 2345 70 50
#description dropbear
[ -r /etc/init.d/functions ] && . /etc/init.d/functions
[ -d /etc/dropbear ] || mkdir /etc/dropbear
Pidfile="/var/run/dropbear.pid" #PID文件路径
Lockfile="/var/lock/subsys/named" #服务锁文件
named="dropbear"
key="dropbearkey"
Dsskey="/etc/dropbear/dropbear_dss_host_key" #dss锁位置
Rsakey="/etc/dropbear/dropbear_rsa_host_key" #rsa锁位置
Port=${Port:=2211} #端口默认制定2211
getdeskey(){
if [ ! -f $Deskey ];then #判断锁文件是否存在
$key -t des -f $$Dsskey &>/dev/null
if [ $? -eq 0 ];then
action "the dsskey is creating on " /bin/true
reture 0
else
action "the dsskey is creating fail " /bin/false
exit 2
fi
else
echo  "the deskey is created" #存在输出created
fi
}
getrsakey(){
if [ ! -f $Rsakey ];then #判断rsa锁文件
$key -t rsa -s 2048 -f $rsakey &>/dev/null
if [ $? -eq 0 ];then
action "the rsakey is creating on " /bin/true
reture 0
else
action "the rsakey is creating fail " /bin/false
exit 2
fi
else
echo "the rsakey is created"
start() {
getdeskey
getrsakey
[ -x "/usr/local/dropbear/sbin/$named" ] || exit 4
if [ -f $Lockfile ];then
echo  "the $named is already running"
exit 5
fi
echo -n "starting $named "
daemon --pidfile "$Pidfile"  /usr/local/dropbear/sbin/dropbear -p $Port
RETAVL=$?
echo
if [ $RETAVL -eq 0 ];then
touch $Lockfile
return 0
else
rm -f $Lockfile $Pidfile
return 1
fi
}
stop(){
if [ ! -f $Lockfile ];then
echo "the $named is stopped.... "
exit 5
fi
echo -n "stopping the $named.."
killproc $named #杀掉服务
RETAVL=$?
echo
if [ $RETAVL -eq 0 ];then
rm -f $Lockfile
fi
}
status(){
if pidof $named &>/dev/null && [ -f $Pidfile ];then
echo "the $named is starting"
else
echo "the $named is stopped"
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
status)
status
;;
*)
echo "Usage:start|stop|restart"
return 5
;;
esac

 

本文出自 “永无止境” 博客,请务必保留此出处http://joe51cto.blog.51cto.com/7680547/1384200

linux下openssh临时替代工具----dropbear,布布扣,bubuko.com

linux下openssh临时替代工具----dropbear

原文:http://joe51cto.blog.51cto.com/7680547/1384200

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!