if not known_hosts will failed
Change-Id: Ic5c6dc664280fc58b772984a5404ceea135ad37c Signed-off-by: Yao Lu <lu.yao135@zte.com.cn>
This commit is contained in:
parent
2cb8a58eee
commit
2c6b2c7143
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#to be trusted by other host£¬and no password needed when use ssh command
|
#to be trusted by other host£¬and no password needed when use ssh command
|
||||||
|
|
||||||
#check parameters legality
|
#check parameters legality
|
||||||
logfile=/var/log/trustme.log
|
logfile=/var/log/trustme.log
|
||||||
@ -48,7 +48,10 @@ keyend="$user@$host"
|
|||||||
print_log "my keyend = $keyend"
|
print_log "my keyend = $keyend"
|
||||||
cmd="sed '/$keyend$/d' -i ~/.ssh/authorized_keys"
|
cmd="sed '/$keyend$/d' -i ~/.ssh/authorized_keys"
|
||||||
print_log "clear my old pub key on $local_host ..."
|
print_log "clear my old pub key on $local_host ..."
|
||||||
ssh-keygen -f "/root/.ssh/known_hosts" -R $ip
|
if [ ! -f /root/.ssh/known_hosts ];then
|
||||||
|
touch /root/.ssh/known_hosts
|
||||||
|
fi
|
||||||
|
ssh-keygen -R $ip
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
print_log "delete pub key of $ip from known_hosts failed"
|
print_log "delete pub key of $ip from known_hosts failed"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user