sshpass自动登录

mac安装


wget http://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz

tar xvzf sshpass-1.05.tar.gz

./configure --prefix=/usr/local/Cellar/sshpass/1.05

make

sudo make install

实例脚本

#!/bin/bash
    host=$1
    case "$host" in
        server1|ip_address1)
            exec sshpass -p password  ssh user@ip_address1 -p22
            ;;
        server2|ip_address2)
            exec sshpass -p password  ssh user@ip_address2 -p22
            ;;
        *)
        echo "no host found"
        ;;
    esac

参考

  • mac下使用sshpass实现ssh记住密码

你可能感兴趣的:(shell,linux)