Module: GitPusshuTen::Helpers::Environment::SCP
- Included in:
- Environment
- Defined in:
- lib/gitpusshuten/helpers/environment/scp.rb
Instance Method Summary collapse
-
#scp_as_root(direction, from, to) ⇒ Object
Establishes a SCP session for “root”.
-
#scp_as_user(direction, from, to) ⇒ Object
Establishes a SCP session for “root”.
Instance Method Details
#scp_as_root(direction, from, to) ⇒ Object
Establishes a SCP session for “root”
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gitpusshuten/helpers/environment/scp.rb', line 32 def scp_as_root(direction, from, to) while true begin Net::SCP.start(c.ip, 'root', { :password => @root_password, :passphrase => c.passphrase, :port => c.port }) do |scp| return scp.send("#{direction}!", from, to) end rescue Net::SSH::AuthenticationFailed if @root_attempted GitPusshuTen::Log.error "Password incorrect. Please retry." else GitPusshuTen::Log. "Please provide the password for #{"root".color(:yellow)}." @root_attempted = true end @root_password = ask('') { |q| q.echo = false } end end end |
#scp_as_user(direction, from, to) ⇒ Object
Establishes a SCP session for “root”
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gitpusshuten/helpers/environment/scp.rb', line 8 def scp_as_user(direction, from, to) while true begin Net::SCP.start(c.ip, 'root', { :password => @user_password, :passphrase => c.passphrase, :port => c.port }) do |scp| return scp.send("#{direction}!", from, to) end rescue Net::SCP::AuthenticationFailed if @user_attempted GitPusshuTen::Log.error "Password incorrect. Please retry." else GitPusshuTen::Log. "Please provide the password for #{c.user.to_s.color(:yellow)}." @user_attempted = true end @user_password = ask('') { |q| q.echo = false } end end end |