1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-23 13:57:52 +00:00

remove mpw-ssh

This commit is contained in:
nishiki 2016-05-08 11:34:29 +02:00
parent dd0e236fc5
commit 85c034b8b3
2 changed files with 0 additions and 131 deletions

View file

@ -1,89 +0,0 @@
#!/usr/bin/ruby
# author: nishiki
# mail: nishiki@yaegashi.fr
# info: a simple script who manage your passwords
require 'rubygems'
require 'optparse'
require 'pathname'
require 'locale'
require 'i18n'
require 'mpw/ui/clissh'
require 'mpw/config'
# --------------------------------------------------------- #
# Set local
# --------------------------------------------------------- #
APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath)
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
if defined?(I18n.enforce_available_locales)
I18n.enforce_available_locales = true
end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = Dir["#{APP_ROOT}/../i18n/cli/*.yml"]
I18n.default_locale = :en
I18n.locale = lang.to_sym
# --------------------------------------------------------- #
# Options
# --------------------------------------------------------- #
options = {}
OptionParser.new do |opts|
opts.banner = "#{I18n.t('ssh.option.usage')}: mpw-ssh SEARCH [options]"
opts.on("-l", "--login LOGIN", I18n.t('ssh.option.login')) do |login|
options[:login] = login
end
opts.on("-s", "--server SERVER", I18n.t('ssh.option.server')) do |server|
options[:server] = server
end
opts.on("-p", "--port PORT", I18n.t('ssh.option.port')) do |port|
options[:port] = port
end
opts.on('-c', '--config CONFIG', I18n.t('cli.option.config')) do |config|
options[:config] = config
end
opts.on("-h", "--help", I18n.t('ssh.option.help')) do
puts opts
exit 0
end
end.parse!
# --------------------------------------------------------- #
# Main
# --------------------------------------------------------- #
config = MPW::Config.new(options[:config])
check_error = config.checkconfig
cli = CliSSH.new(config)
cli.login = options[:login]
cli.server = options[:server]
cli.port = options[:port]
search = ARGV[0]
# Setup a new config
if not check_error
cli.setup(lang)
elsif ARGV.length < 1
puts "#{I18n.t('ssh.option.usage')}: mpw-ssh SEARCH [options]"
exit 2
else
cli.decrypt
cli.sync
cli.ssh(search)
end
cli = nil
exit 0

View file

@ -1,42 +0,0 @@
#!/usr/bin/ruby
# author: nishiki
# mail: nishiki@yaegashi.fr
# info: a simple script who manage your passwords
require 'mpw/ui/cli'
class CliSSH < Cli
attr_accessor :server, :port, :login
# Connect to SSH
# args: search -> string to search
def ssh(search)
result = @mpw.list(search: search, protocol: 'ssh')
if result.length > 0
result.each do |item|
server = @server.nil? ? item.host : @server
port = @port.nil? ? item.port : @port
login = @login.nil? ? item.user : @login
passwd = item.password
if port.nil? and port.empty?
port = 22
end
puts "#{I18n.t('ssh.display.connect')} ssh #{login}@#{server} -p #{port}"
if passwd.empty?
system("ssh #{login}@#{server} -p #{port}")
else
system("sshpass -p '#{passwd}' ssh #{login}@#{server} -p #{port}")
end
end
else
puts I18n.t('ssh.display.nothing')
end
end
end