输入ip密码,建立主机信任脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了输入ip密码,建立主机信任脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash
# Date: 2015.11.13
# Description: first,build the need files,second push to the machine.
# you need to input your host ip
# Version: 0.0.1
echo "the mine key will come to"
[ ! -f /root/.ssh/id_rsa ] && ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ‘‘
[ -f /root/.ssh/id_rsa.pub ] && cat /root/.ssh/id_rsa.pub > /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys
while true
do
read -p "please input the host (you want to login): " HOST
echo "$HOST"|egrep ‘\<([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>‘ || echo "the ip has problems" || exit 1
ssh [email protected]"$HOST" "test ! -d /root/.ssh && mkdir /root/.ssh && chmod 700 /root/.ssh"
scp -p /root/.ssh/{id_rsa,authorized_keys} [email protected]"$HOST":/root/.ssh
done
# 感觉脚本写的挺蹩脚,下次加油!
本文出自 “Linux” 博客,请务必保留此出处http://ridingonhorse.blog.51cto.com/11265295/1872409
以上是关于输入ip密码,建立主机信任脚本的主要内容,如果未能解决你的问题,请参考以下文章