mac使用sshpass登录服务器

mac使用sshpass 登录服务器

      • 安装sshpass
      • 登录脚本

安装sshpass

下载地址:https://sourceforge.net/projects/sshpass/
安装脚本:

tar xvzf sshpass-1.05.tar.gz  
cd sshpass-1.0.5
./configure  
make  
sudo make install 

登录脚本

#!/bin/bash
host=$1   
    echo "Your choose:$host"  
    case "$host" in  
        10)  
        exec /usr/local/bin/sshpass -p '123456'  ssh [email protected] -p22  
        ;;  
        11)  
        exec /usr/local/bin/sshpass -p '123456'  ssh [email protected] -p22
        ;;  
        family)
        exec /usr/local/bin/sshpass -p 'password' ssh user@ip -p22
        ;;  
        *)  
        echo "Error, No host"  
        ;;  
    esac 

你可能感兴趣的:(Linux)