1,ssh
ssh 端口为默认22的时候:
sshpass -p 888888 scp -o StrictHostKeyChecking=no /root/images.zip root@21.1.9.1:/root/
sshpass -p 888888 ssh -o StrictHostKeyChecking=no root@21.1.9.1 "unzip -o /root/images.zip -d /"
#sshpass -p userpassword ssh -o StrictHostKeyChecking=no username@serverip "ls /"
ssh 端口不是默认22的时候,假如为1234
#sshpass -p userpassword ssh -o StrictHostKeyChecking=no -p1234 username@serverip "ls /"
2,scp
sshpass -p "$2" scp -r -o StrictHostKeyChecking=no $srcfile username@hostname:$descPath
3,sftp
sshpass -p "$2" sftp -o StrictHostKeyChecking=no username@hostname:$romotefilename $localpath
下载
Linux基于sshpass小工具,用于非交互的ssh操作
ubuntu 安装 apt-get install sshpass
sshpass下载地址:http://sourceforge.net/projects/sshpass/
censot6 安装
tar zxvf sshpass-1.06.tar.gz
cd sshpass-1.06
./configure ##--prefix=/opt/sshpass
make
make install