mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +00:00
Add mpw-ssh
This commit is contained in:
parent
54fd0659d7
commit
417506d693
4 changed files with 59 additions and 0 deletions
0
Cli.rb
Executable file → Normal file
0
Cli.rb
Executable file → Normal file
37
CliSSH.rb
Normal file
37
CliSSH.rb
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
# author: nishiki
|
||||||
|
# mail: nishiki@yaegashi.fr
|
||||||
|
# info: a simple script who manage your passwords
|
||||||
|
|
||||||
|
require 'net/ssh'
|
||||||
|
require "#{APP_ROOT}/Cli.rb"
|
||||||
|
|
||||||
|
class CliSSH < Cli
|
||||||
|
|
||||||
|
def ssh(search)
|
||||||
|
result = @m.search(search, 'ssh')
|
||||||
|
|
||||||
|
if result.length > 0
|
||||||
|
result.each do |r|
|
||||||
|
server = r[MPW::SERVER]
|
||||||
|
login = r[MPW::LOGIN]
|
||||||
|
port = r[MPW::PORT]
|
||||||
|
passwd = r[MPW::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
|
||||||
|
|
||||||
|
else
|
||||||
|
puts "Nothing result!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
0
MPW.rb
Executable file → Normal file
0
MPW.rb
Executable file → Normal file
22
mpw-ssh
Executable file
22
mpw-ssh
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
# author: nishiki
|
||||||
|
# mail: nishiki@yaegashi.fr
|
||||||
|
# info: a simple script who manage your passwords
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
|
require 'pathname'
|
||||||
|
|
||||||
|
APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath)
|
||||||
|
require "#{APP_ROOT}/CliSSH.rb"
|
||||||
|
|
||||||
|
if ARGV.length != 1
|
||||||
|
puts "Usage: mpw-ssh search"
|
||||||
|
exit 2
|
||||||
|
end
|
||||||
|
|
||||||
|
search = ARGV[0]
|
||||||
|
|
||||||
|
cli = CliSSH.new()
|
||||||
|
cli.ssh(search)
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Add table
Reference in a new issue