You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

17 lines
319 B

#!/bin/bash
set -e #如果某条指令执行出错,则会退出脚本
if [ $# -eq 0 ]; then
echo "Usage: $0 <ip>"
exit 1
fi
# 检查ssh-key是否存在,不存在则退出
if [ ! -f ~/.ssh/id_rsa.pub ]; then
echo "ssh-key not found, please run ssh-keygen first"
exit 1
fi
ip=$1
ssh-copy-id root@${ip}