lib/ssh/manager/cli.rb in ssh-manager-1.0.1 vs lib/ssh/manager/cli.rb in ssh-manager-1.0.2
- old
+ new
@@ -32,13 +32,21 @@
puts 'Check Github for further development or contributing'
end
end
def connect_to(id)
- @ip = DATABASE.get_connection_data[id.to_i-1][0]
- @user = DATABASE.get_connection_data[id.to_i-1][1]
- check_term(@ip, @user)
+ via = DATABASE.get_connection_data[id.to_i-1][-1] =~ /@/
+ if via.integer? == false
+ @ip = DATABASE.get_connection_data[id.to_i-1][0]
+ @user = DATABASE.get_connection_data[id.to_i-1][1]
+ check_term(@ip, @user)
+ else
+ @ip = DATABASE.get_connection_data[id.to_i-1][0]
+ @user = DATABASE.get_connection_data[id.to_i-1][1]
+ via = DATABASE.get_connection_data[id.to_i-1][-1]
+ %x(gnome-terminal --command="ssh -A -t #{via} ssh -A -t #{@user}@#{@ip}")
+ end
#TODO: check for options
#TODO: if db[secure_login] = false => http://linuxcommando.blogspot.de/2008/10/how-to-disable-ssh-host-key-checking.html
end
def update_available
@@ -78,18 +86,19 @@
puts 'Options: '
options = $stdin.gets.chomp
options = '' if options == ''
puts 'Group: '
group = $stdin.gets.chomp
- # puts 'Connect via(ip): '
- # connect_via_ip = $stdin.gets.chomp
- # puts 'With Username: '
- # connect_via_user = $stdin.gets.chomp
- # connect_via= "#{connect_via_user}@#{connect_via_ip}"
+ puts 'Connect via(ip): '
+ connect_via_ip = $stdin.gets.chomp
+ puts 'With Username: '
+ connect_via_user = $stdin.gets.chomp
+ connect_via= "#{connect_via_user}@#{connect_via_ip}"
+ # ssh -A -t jxs@10.160.64.184 ssh -A -t tux@10.160.65.2
count = 0
created_at = Time.now.to_s
last_time = Time.now.to_s
- DATABASE.add_new_connection(ip, user, hostname, port, note, created_at, options, count, group, last_time)
+ DATABASE.add_new_connection(ip, user, hostname, port, note, connect_via, created_at, options, count, group, last_time)
end
def delete(id)
id = id.to_i - 1
DATABASE.delete_connection(DATABASE.get_connection_data[id][0])