Linux sshpassを使ってパスワード指定のSSH接続を行う方法

概要
sshコマンド実行前にsshpassでパスワードを指定する
$ sshpass -p パスワード ssh ホスト名 -l ユーザ名

ファイルからパスワードを取得させる
$ sshpass -f ファイルのパス ssh ホスト名 -l ユーザ名

インストールの方法
1.RHEL系の場合
インストールの方法

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo yum install sshpass --enablerepo=epel
# sudo yum install sshpass --enablerepo=epel
# sudo yum install sshpass --enablerepo=epel

2.Debian/Ubuntu系の場合
インストールの方法
$ sudo apt-get install sshpass

3.ソースコードからファイルをビルドする

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ wget http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/sshpass-1.05.tar.gz
$ tar -xzvf sshpass-1.05.tar.gz
$ cd sshpass-1.05
$ ./configure && make && make install
$ wget http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/sshpass-1.05.tar.gz $ tar -xzvf sshpass-1.05.tar.gz $ cd sshpass-1.05 $ ./configure && make && make install
$ wget http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/sshpass-1.05.tar.gz
$ tar -xzvf sshpass-1.05.tar.gz
$ cd sshpass-1.05
$ ./configure && make && make install

 

Linux

Posted by arkgame