1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-20 01:50:04 +00:00

remove ssh connection in mpw

This commit is contained in:
nishiki 2013-08-06 21:42:47 +02:00
parent 505da7747f
commit 54fd0659d7
3 changed files with 0 additions and 42 deletions

3
Cli.rb
View file

@ -158,7 +158,4 @@ class Cli
end
def ssh(search)
@m.ssh(search)
end
end

31
MPW.rb
View file

@ -6,7 +6,6 @@
require 'rubygems'
require 'gpgme'
require 'csv'
require 'net/ssh'
require 'yaml'
class MPW
@ -319,35 +318,5 @@ class MPW
return false
end
end
# Connect to ssh && display the password
# @args: file -> a string to match
# @rtrn: true if ssh connection work
def ssh(search)
result = self.search(search, 'ssh')
if result.length > 0
result.each do |r|
server = r[SERVER]
login = r[LOGIN]
port = r[PORT]
passwd = r[PASSWORD]
if port.empty?
port = 22
end
if passwd.empty?
system("#{passwd} ssh #{login}@#{server} -p #{port}")
else
system("sshpass -p #{passwd} ssh #{login}@#{server} -p #{port}")
end
end
return true
else
return false
end
end
end

8
mpw
View file

@ -39,10 +39,6 @@ OptionParser.new do |opts|
options[:setup] = true
end
opts.on("-s", "--ssh SEARCH", "Connect to ssh") do |search|
options[:ssh] = search
end
opts.on("-p", "--protocol PROTOCOL", "Select a protocol") do |type|
options[:type] = type
end
@ -92,10 +88,6 @@ elsif not options[:remove].nil?
elsif not options[:update].nil?
cli.update(options[:update])
# Connect to ssh
elsif not options[:ssh].nil?
cli.ssh(options[:ssh])
# Add a new item
elsif not options[:add].nil?
cli.add()