JavaScript must be enabled in order for you to see "WP Copy Data Protect" effect. However, it seems JavaScript is either disabled or not supported by your browser. To see full result of "WP Copy Data Protector", enable JavaScript by changing your browser options, then try again.

Usage about the sshpass


話說有將近一個月沒有Po廢文了,因為最近剛好遇到外公不幸逝世,以及準備CCDA的考試,所以沒有按照一周一廢文Rule,而且SEO感覺有往下Fu;話不多說,直接上今天的Topic,就是大名鼎鼎的SSHPass,目標可以達成無互動的方式SSH的Session,一般傳統都是用SSH Keypair的方式來達到此目的(空白的Passphrase),但設定時還是需要Key In密碼,對於非常Lazy的我來說,這可是行不通的,不像SSHPass可以透過Parameter的方式密碼嵌入,有利於自動化Script的Progress,那細部要如何Operate呢,讓我們繼續看下去吧!

1) Install the util of sshpass(可透過Source的Tarball或Package做安裝)
#tar zxvf sshpass-<Version>.tar.gz
#cd sshpass-<Version>
#./configure && make && make install
#rpm -ivh sshpass-<Version>.rpm
#dpkg -i sshpass-<Version>.deb
#apt-get install sshpass
#yum install sshapass

2) Sample about usage of sshpass through command
#sshpass -p '<PASSWORD>' scp <USERNAME>@<HOST>:<Remote PATH of File> <Local Path>
#sshpass -p '<PASSWORD>' ssh <USERNAME>@<HOST>
#sshpass -p '<PASSWORD>' rsync -a -v <USERNAME>@<HOST>:<Remote PATH of File> <Local Path>

3) Sample about usage of sshpass through file
#echo '<PASSWORD>' > SSHPASSWORD
#sshpass -f SSHPASSWORD ssh <USERNAME>@<HOST>

4) Sample about usage of sshpass through env variable
#SSHPASS='<PASSWORD>'; sshpass -e ssh <USERNAME>@<HOST>
#export SSHPASS='<PASSWORD>'
#sshpass -e ssh <USERNAME>@<HOST>
#unset SSHPASS

5) Sample about usage of sshpass through Stdin
#echo '<PASSWORD>' | sshpass -d 0 ssh <USERNAME>@<HOST> '<COMMAND>'

6) 透過SSH本身的Parameter去Omit交換公鑰的Check訊息
#ssh -o StrictHostKeyChecking=no <USERNAME>@<HOST>
#vi /etc/ssh/ssh_config
StrictHostKeyChecking no

7) 暫時Disable History的Record during sshpassing
#set +o history -> Disable
Process about sshpassing...
#set -o history -> Enable

◎、以上就是針對SSHPass的使用方式做個簡單介紹,事實上還有其他方式可以達成,如Python或Expect等等,就留到下次有機會做介紹吧;上述均參考Jamyy大大的這篇文章,想看到更多Detail的介紹可以到他那邊欣賞欣賞唷,先到這,收工囉!

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
This site is protected by WP-CopyRightPro