ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Solairs 变更IP 及 SSH 问题

Solairs 变更IP 及 SSH 问题

原创 Linux操作系统 作者:flying_warrior 时间:2010-12-27 16:35:27 0 删除 编辑
机器换机房 IP 变更。

2台Solaris 10的测试机需要变更IP。

修改/etc/hosts 
将原来的
192.168.16.xxxs hostname loghost
改为
192.168.8.xxx hostname  loghost

2.需要设置网关才可以访问
其中一台机器配置过网关 一台未配置
配置过的 需要修改 /etc/defaultrouter
将原来的  192.168.16.xxx 改为192.168.8.1
未配置过的 删除了/etc/notrouter
vi /etc/defaultrouter  新增一行 192.168.8.1

reboot 就OK了

其中有个小插曲 。原先其中一台机器的 IP是 192.168.16.230 后改为192.168.8.230后 
在自己的机器ping 192.168.8.230  时断时续  。
ssh  root上去 提示 密码不对
我对ssh 不熟悉 以为是 换了IP 连key 都变了 于是便删除了 /etc/ssh/ssh_host*的文件。看看重新连接能不能重建。
等再尝试连接的时候 报错 no kex alg ……

于是需要重新生成 这些文件
    * /etc/ssh/ssh_host_dsa_key
    * /etc/ssh/ssh_host_dsa_key.pub
    * /etc/ssh/ssh_host_key
    * /etc/ssh/ssh_host_key.pub
    * /etc/ssh/ssh_host_rsa_key
    * /etc/ssh/ssh_host_rsa_key.pub
下面附上脚本

#!/bin/sh
# sshd-key-gen.sh
# post-apply script. that properly manages ssh authentication keys
# Install in /var/radmind/postapply

SSHKEYGEN=/usr/bin/ssh-keygen

if [ ! -s /etc/ssh/ssh_host_key -o ! -s /etc/ssh/ssh_host_key.pub ]; then
    if [ -f /etc/ssh/ssh_host_key ]; then
        rm /etc/ssh/ssh_host_key
    fi
    if [ -f /etc/ssh/ssh_host_key.pub ]; then
        rm /etc/ssh/ssh_host_key.pub
    fi
    $SSHKEYGEN -q -t rsa1 -f /etc/ssh/ssh_host_key -N "" \
        -C "" < /dev/null > /dev/null 2> /dev/null
    echo "Created /etc/ssh/ssh_host_key"
fi

if [ ! -s /etc/ssh/ssh_host_rsa_key -o ! -s /etc/ssh/ssh_host_rsa_key.pub ]; then
    if [ -f /etc/ssh/ssh_host_rsa_key ]; then
        rm /etc/ssh/ssh_host_rsa_key
    fi
    if [ -f /etc/ssh/ssh_host_rsa_key.pub ]; then
        rm /etc/ssh/ssh_host_rsa_key.pub
    fi
    $SSHKEYGEN -q -t rsa  -f /etc/ssh/ssh_host_rsa_key -N "" \
        -C "" < /dev/null > /dev/null 2> /dev/null
    echo "Created /etc/ssh/ssh_host_rsa_key"
fi

if [ ! -s /etc/ssh/ssh_host_dsa_key -o ! -s /etc/ssh/ssh_host_dsa_key.pub ]; then
    if [ -f /etc/ssh/ssh_host_dsa_key ]; then
        rm /etc/ssh/ssh_host_dsa_key
    fi
    if [ -f /etc/ssh/ssh_host_dsa_key.pub ]; then
        rm /etc/ssh/ssh_host_dsa_key.pub
    fi
    $SSHKEYGEN -q -t dsa -f /etc/ssh/ssh_host_dsa_key -N "" \
        -C "" < /dev/null > /dev/null 2> /dev/null
    echo "Created /etc/ssh/ssh_host_dsa_key"
fi

exit 0


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21818314/viewspace-682666/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-06-21

  • 博文量
    49
  • 访问量
    89722