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.

16 lines
319 B

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