老谢博客

  • 首页
  • WordPress
  • 网络技术
  • 乱七八糟
  • 运维技术
  • 给我留言
  • 关于老谢

CentOS无法启动SSH报错:Auto configuration failed

分类:linux日期:2013-03-14 - 13:42:43作者:老谢

重装SSH,步骤如下:

[root@node1 ~]# rpm -aq|grep ssh
openssh-askpass-4.3p2-29.el5
openssh-server-4.3p2-29.el5
openssh-4.3p2-29.el5
openssh-clients-4.3p2-29.el5
[root@node1 ~]# rpm -e openssh-askpass-4.3p2-29.el5
[root@node1 ~]# rpm -e openssh-server-4.3p2-29.el5
[root@node1 ~]# rpm -e openssh-clients-4.3p2-29.el5
[root@node1 ~]# rpm -e openssh-4.3p2-29.el5
[root@node1 ~]# wget ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-5.5p1.tar.gz
[root@node1 ~]# gunzip openssh-5.5p1.tar.gz
[root@node1 ~]# tar -xvf openssh-5.5p1.tar
[root@node1 ~]# cd openssh-5.5p1
[root@node1 ~]# ./configure
[root@node1 ~]# make && make instal
[root@node1 ~]# vim /etc/init.d/sshd

[root@node1 ~]# rpm -aq|grep ssh openssh-askpass-4.3p2-29.el5 openssh-server-4.3p2-29.el5 openssh-4.3p2-29.el5 openssh-clients-4.3p2-29.el5 [root@node1 ~]# rpm -e openssh-askpass-4.3p2-29.el5 [root@node1 ~]# rpm -e openssh-server-4.3p2-29.el5 [root@node1 ~]# rpm -e openssh-clients-4.3p2-29.el5 [root@node1 ~]# rpm -e openssh-4.3p2-29.el5 [root@node1 ~]# wget ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-5.5p1.tar.gz [root@node1 ~]# gunzip openssh-5.5p1.tar.gz [root@node1 ~]# tar -xvf openssh-5.5p1.tar [root@node1 ~]# cd openssh-5.5p1 [root@node1 ~]# ./configure [root@node1 ~]# make && make instal [root@node1 ~]# vim /etc/init.d/sshd

编辑下面的内容进去:

#!/bin/bash
#
# Init file for OpenSSH server daemon
#
# chkconfig: 2345 55 25
# description: OpenSSH server daemon
#
# processname: sshd
# config: /etc/ssh/ssh_host_key
# config: /etc/ssh/ssh_host_key.pub
# config: /etc/ssh/ssh_random_seed
# config: /etc/ssh/sshd_config
# pidfile: /var/run/sshd.pid
 
# source function library
. /etc/rc.d/init.d/functions
 
# pull in sysconfig settings
[ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd
 
RETVAL=0
prog="sshd"
 
# Some functions to make the below more readable
KEYGEN=/usr/bin/ssh-keygen
SSHD=/usr/local/sbin/sshd
RSA1_KEY=/etc/ssh/ssh_host_key
RSA_KEY=/etc/ssh/ssh_host_rsa_key
DSA_KEY=/etc/ssh/ssh_host_dsa_key
PID_FILE=/var/run/sshd.pid
 
runlevel=$(set -- $(runlevel); eval "echo \$$#" )
 
do_rsa1_keygen() {
        if [ ! -s $RSA1_KEY ]; then
                echo -n $"Generating SSH1 RSA host key: "
                rm -f $RSA1_KEY
                if $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then
                        chmod 600 $RSA1_KEY
                        chmod 644 $RSA1_KEY.pub
                        if [ -x /sbin/restorecon ]; then
                            /sbin/restorecon $RSA1_KEY.pub
                        fi
                        success $"RSA1 key generation"
                        echo
                else
                        failure $"RSA1 key generation"
                        echo
                        exit 1
                fi
        fi
}
 
do_rsa_keygen() {
        if [ ! -s $RSA_KEY ]; then
                echo -n $"Generating SSH2 RSA host key: "
                rm -f $RSA_KEY
                if $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then
                        chmod 600 $RSA_KEY
                        chmod 644 $RSA_KEY.pub
                        if [ -x /sbin/restorecon ]; then
                            /sbin/restorecon $RSA_KEY.pub
                        fi
                        success $"RSA key generation"
                        echo
                else
                        failure $"RSA key generation"
                        echo
                        exit 1
                fi
        fi
}
 
do_dsa_keygen() {
        if [ ! -s $DSA_KEY ]; then
                echo -n $"Generating SSH2 DSA host key: "
                rm -f $DSA_KEY
                if $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then
                        chmod 600 $DSA_KEY
                        chmod 644 $DSA_KEY.pub
                        if [ -x /sbin/restorecon ]; then
                            /sbin/restorecon $DSA_KEY.pub
                        fi
                        success $"DSA key generation"
                        echo
                else
                        failure $"DSA key generation"
                        echo
                        exit 1
                fi
        fi
}
 
do_restart_sanity_check()
{
        $SSHD -t
        RETVAL=$?
        if [ ! "$RETVAL" = 0 ]; then
                failure $"Configuration file or keys are invalid"
                echo
        fi
}
 
start()
{
        # Create keys if necessary
        do_rsa1_keygen
        do_rsa_keygen
        do_dsa_keygen
 
        cp -af /etc/localtime /var/empty/sshd/etc
 
        echo -n $"Starting $prog: "
        $SSHD $OPTIONS && success || failure
        RETVAL=$?
        [ "$RETVAL" = 0 ] && touch /var/lock/subsys/sshd
        echo
}
 
stop()
{
        echo -n $"Stopping $prog: "
        if [ -n "`pidfileofproc $SSHD`" ] ; then
            killproc $SSHD
        else
            failure $"Stopping $prog"
        fi
        RETVAL=$?
        # if we are in halt or reboot runlevel kill all running sessions
        # so the TCP connections are closed cleanly
        if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then
            killall $prog 2>/dev/null
        fi
        [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/sshd
        echo
}
 
reload()
{
        echo -n $"Reloading $prog: "
        if [ -n "`pidfileofproc $SSHD`" ] ; then
            killproc $SSHD -HUP
        else
            failure $"Reloading $prog"
        fi
        RETVAL=$?
        echo
}
 
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        reload)
                reload
                ;;
        condrestart)
                if [ -f /var/lock/subsys/sshd ] ; then
                        do_restart_sanity_check
                        if [ "$RETVAL" = 0 ] ; then
                                stop
                                # avoid race
                                sleep 3
                                start
                        fi
                fi
                ;;
        status)
                status -p $PID_FILE openssh-daemon
                RETVAL=$?
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
                RETVAL=1
esac
exit $RETVAL

#!/bin/bash # # Init file for OpenSSH server daemon # # chkconfig: 2345 55 25 # description: OpenSSH server daemon # # processname: sshd # config: /etc/ssh/ssh_host_key # config: /etc/ssh/ssh_host_key.pub # config: /etc/ssh/ssh_random_seed # config: /etc/ssh/sshd_config # pidfile: /var/run/sshd.pid # source function library . /etc/rc.d/init.d/functions # pull in sysconfig settings [ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd RETVAL=0 prog="sshd" # Some functions to make the below more readable KEYGEN=/usr/bin/ssh-keygen SSHD=/usr/local/sbin/sshd RSA1_KEY=/etc/ssh/ssh_host_key RSA_KEY=/etc/ssh/ssh_host_rsa_key DSA_KEY=/etc/ssh/ssh_host_dsa_key PID_FILE=/var/run/sshd.pid runlevel=$(set -- $(runlevel); eval "echo \$$#" ) do_rsa1_keygen() { if [ ! -s $RSA1_KEY ]; then echo -n $"Generating SSH1 RSA host key: " rm -f $RSA1_KEY if $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then chmod 600 $RSA1_KEY chmod 644 $RSA1_KEY.pub if [ -x /sbin/restorecon ]; then /sbin/restorecon $RSA1_KEY.pub fi success $"RSA1 key generation" echo else failure $"RSA1 key generation" echo exit 1 fi fi } do_rsa_keygen() { if [ ! -s $RSA_KEY ]; then echo -n $"Generating SSH2 RSA host key: " rm -f $RSA_KEY if $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then chmod 600 $RSA_KEY chmod 644 $RSA_KEY.pub if [ -x /sbin/restorecon ]; then /sbin/restorecon $RSA_KEY.pub fi success $"RSA key generation" echo else failure $"RSA key generation" echo exit 1 fi fi } do_dsa_keygen() { if [ ! -s $DSA_KEY ]; then echo -n $"Generating SSH2 DSA host key: " rm -f $DSA_KEY if $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then chmod 600 $DSA_KEY chmod 644 $DSA_KEY.pub if [ -x /sbin/restorecon ]; then /sbin/restorecon $DSA_KEY.pub fi success $"DSA key generation" echo else failure $"DSA key generation" echo exit 1 fi fi } do_restart_sanity_check() { $SSHD -t RETVAL=$? if [ ! "$RETVAL" = 0 ]; then failure $"Configuration file or keys are invalid" echo fi } start() { # Create keys if necessary do_rsa1_keygen do_rsa_keygen do_dsa_keygen cp -af /etc/localtime /var/empty/sshd/etc echo -n $"Starting $prog: " $SSHD $OPTIONS && success || failure RETVAL=$? [ "$RETVAL" = 0 ] && touch /var/lock/subsys/sshd echo } stop() { echo -n $"Stopping $prog: " if [ -n "`pidfileofproc $SSHD`" ] ; then killproc $SSHD else failure $"Stopping $prog" fi RETVAL=$? # if we are in halt or reboot runlevel kill all running sessions # so the TCP connections are closed cleanly if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then killall $prog 2>/dev/null fi [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/sshd echo } reload() { echo -n $"Reloading $prog: " if [ -n "`pidfileofproc $SSHD`" ] ; then killproc $SSHD -HUP else failure $"Reloading $prog" fi RETVAL=$? echo } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; reload) reload ;; condrestart) if [ -f /var/lock/subsys/sshd ] ; then do_restart_sanity_check if [ "$RETVAL" = 0 ] ; then stop # avoid race sleep 3 start fi fi ;; status) status -p $PID_FILE openssh-daemon RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" RETVAL=1 esac exit $RETVAL

[root@node1 ~]# service sshd start
[root@node1 ~]# chkconig sshd on

[root@node1 ~]# service sshd start [root@node1 ~]# chkconig sshd on

原文地址 : https://www.xj123.info/3418.html

本站遵循 : 署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5)

版权声明 : 原创文章转载时,请务必以超链接形式标明文章原始出处

  • 上一篇:黑武士
  • 下一篇:DirectAdmin重建httpd.conf
1条评论
  1. 销声匿迹 说:

    为毛不用yum涅,,,,,,

    POST:2013-04-25 17:29 回复
发表评论 点击取消评论.

*必填

*必填

  • 文章归档
  • 子网计算
  • 我的共享
  • 锻炼计划
  • 给我留言
  • 关于老谢
2023年 4月
一 二 三 四 五 六 日
 12
3456789
10111213141516
17181920212223
24252627282930
« 10月    

最新文章

  • 2021好久没更新博客
  • Zabbix监控oxidized备份状态
  • Zabbix 5.0 LTS版本MySQL表分区及编译安装随记
  • centos7.9部署oxidized自动备份交换机配置
  • Surface Pro 4更换屏幕与电池
  • VCSA中删除horizon view链接克隆生成的replica-受保护副本
  • Esxi6.7U3安装SanDisk Fusion-io 1.3T ioscale Pci SSD加速卡驱动
  • 搭建ELK日志系统分析处理fortigate的syslog日志
  • 华为USG防火墙配置NAT映射回流解决内网通过公网映射访问内部服务器
  • 飞塔防火墙fortitoken配置

最新评论

  • 无敌风火轮:和索尼没啥关系,这是索尼电脑的...
  • zhudong:老大,有VMware Horizon 7.12相关资...
  • qx:所有连接失效了,求一份
  • RainH:大佬,这个111.111.111.111是什么鬼?...
  • 王叨叨:幸福的人都是相似的,不幸的人各有各...
  • 李海博客:李海博客前来学习!
  • 明月登楼:最近使用了ZeroSSL证书,感觉还不...
  • 鸟叔:尽管不知道干啥的,还是来顶一下
  • 鸟叔:鸟叔来贵博客参观学习,通过十年之约穿...
  • 周良粥凉:往前看。

日志存档

  • 2021年10月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2020年11月
  • 2020年9月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年1月
  • 2019年12月
  • 2019年10月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年3月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年1月
  • 2017年10月
  • 2017年9月
  • 2017年8月
  • 2017年7月
  • 2017年2月
  • 2017年1月
  • 2016年12月
  • 2016年11月
  • 2016年10月
  • 2016年7月
  • 2016年6月
  • 2016年4月
  • 2016年2月
  • 2016年1月
  • 2015年12月
  • 2015年10月
  • 2015年9月
  • 2015年7月
  • 2015年5月
  • 2015年4月
  • 2015年3月
  • 2015年2月
  • 2015年1月
  • 2014年12月
  • 2014年10月
  • 2014年9月
  • 2014年8月
  • 2014年7月
  • 2014年6月
  • 2014年5月
  • 2014年4月
  • 2014年3月
  • 2014年2月
  • 2014年1月
  • 2013年12月
  • 2013年11月
  • 2013年10月
  • 2013年9月
  • 2013年8月
  • 2013年7月
  • 2013年6月
  • 2013年5月
  • 2013年4月
  • 2013年3月
  • 2013年2月
  • 2013年1月
  • 2012年12月
  • 2012年11月
  • 2012年9月
  • 2012年8月
  • 2012年7月
  • 2012年6月
  • 2012年5月
  • 2012年4月
  • 2012年3月
  • 2012年2月
  • 2012年1月
  • 2011年12月
  • 2011年11月
  • 2011年10月
  • 2011年9月
  • 2011年8月
  • 2011年7月
  • 2011年6月
  • 2011年5月
  • 2011年4月
  • 2011年3月
  • 2011年2月
  • 2011年1月
  • 2010年12月
  • 2010年11月
  • 2010年10月
  • 2010年9月
  • 2010年8月
  • 2010年7月

W3C

  • XHTML 1.0 Transitional
  • CSS level 3
  • Google+
Copyright © 2010-2023 老谢博客 All rights reserved.
Gzipped 76.5% | Optimized loading 59 queries in 0.261 seconds | Memory 33.55 MB | 皖ICP备13010663号-1
Powered by WordPress. | Hosted By 腾讯云 | Theme by WordPress主题巴士 | 站点地图 | SiteMap | Uptime | 技术支持:苏州天剑计算机系统有限公司