6 ssh.lua - SSH menu for known hosts.
12 wmii.load_plugin ("ssh")
13 wmii.add_key_handler ("Mod1-z", ssh.show_menu)
19 This reads ~/.ssh/known_hosts in order to display a menu of hosts (and IP
20 addresses) found in the file. It assumes 'HashKnownHosts no' is set in
21 ~/.ssh/config (otherwise it displays the hashed hosts).
29 David Leadbeater <dgl@dgl.cx>
31 =head1 LICENCE AND COPYRIGHT
33 Copyright (c) 2008, David Leadbeater <dgl@dgl.cx>
35 This is free software. You may redistribute copies of it under the terms of
36 the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>. There
37 is NO WARRANTY, to the extent permitted by law.
42 local wmii
= require("wmii")
43 local os
= require("os")
44 local io
= require("io")
55 local file
= io
.open(os
.getenv("HOME") .. "/.ssh/known_hosts", "r")
57 local line
= file
:read("*line")
60 local host
= line
:match("([^ ,]+)")
62 line
= file
:read("*line")
69 local str
= wmii
.menu(hosts
, "ssh:")
70 if type(str
) == "string" then
71 local cmd
= wmii
.get_conf("xterm") .. " -e ssh " .. str
.. " &"