sshpass的安裝使用


1:sshpass下載與安裝
yum安裝:
yum install sshpass
若yum安裝不上,則用下面方法
https://sourceforge.net/projects/sshpass/files/
or
https://pan.baidu.com/s/1pLNxeLd
or
wget http://sourceforge.net/projects/sshpass/files/latest/download -O sshpass.tar.gz


2:下載后,解壓,安裝
tar -zxvf sshpass-1.06.tar.gz
cd sshpass-1.06
./configure
make
make install

3:使用命令

sshpass -p 123456 scp /home/file.txt root@10.0.0.37:/home/copy


后面這個是 “Are you sure you want to continue connecting (yes/no)”使得這個自動接受,若不加,則成功不了

4:腳本

#!/bin/bash
password=123456
user=root
ip=10.0.0.37
file=/home/file.txt
sshpass -p $password scp file $user@$ip:/home/copy/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM