LoginSignup
4
3

More than 5 years have passed since last update.

itamaeでremote_fileを実行した際に「SCP did not finish successfully: (Net::SCP::Error)」が出る場合の対処法

Last updated at Posted at 2015-08-25

LinuxのディストリはScientific Linux 6.0です。

$ cat /etc/redhat-release
Scientific Linux release 6.0 (Carbon)

itamaeでremote_fileを実行した際に、下記のようなエラーが発生しました。

$ itamae ssh -h servername -u root recipes/vim_setting.rb --log-level debug

 INFO : Recipe: /Users/yuto/Work/vagrant/dahack/recipes/vim_setting.rb
DEBUG :   remote_file[/root/.vimrc]
DEBUG :     remote_file[/root/.vimrc] action: create
DEBUG :       (in pre_action)
DEBUG :       Sending a file from '/Users/yuto/Work/vagrant/dahack/recipes/remote_files/vimrc' to '/tmp/itamae_tmp/1440518054.496387'...
/Users/yuto/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/net-scp-1.2.1/lib/net/scp.rb:365:in `block (3 levels) in start_command': SCP did not finish successfully (127):  (Net::SCP::Error)

Stackoverflowによると、該当するファイルが存在しない場合にこのエラーが出るとのことでしたが、ファイル名やパスは間違っておらず、実行ユーザーのアクセス権も問題ありません。

該当するgemのコード(scp.rbの365)行目あたりを読んでみると、下記のようなコードが発行されていました。

scp -t /tmp/1440518054.496387

サーバーにログインして上記コードを実行してみると、そもそもscpコマンドがインストールされていないことがわかりました。

CentOS 6.x/Scientific Linux 6.xサーバーへscpコマンドを使う場合

上記ブログによると、最小構成でインストールしたScientific Linuxにはscpコマンドがインストールされない、とのこと。
scpはopenssl-clientパッケージに含まれているそうなので、remote_fileを実行するレシピの前にpackageでopenssh-clientsをインストールするように修正して解決しました。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3