~bernd-sch/onehundredscopes/sshsearch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
SSHSearch Unity Lens Daemon written in Python
-----------------------------------------------

Features
--------

 * it parses the ~/.ssh/config file and searches for the hostnames
 * it parses the ~/.ssh/known_hosts file and reads all hostnames (to use this feature you have to set the ssh setting "HashKnownHosts" to "no")
 * you are able to define a user for the founded hosts in the search term

Examples
--------

Assume the ~/.ssh/config file looks like

    Host desktop
    User user
    HostName 192.168.1.100
    
    Host desktop1
    User user
    HostName 192.168.1.101

    host vserver
    User user
    Port 2222
    HostName 11.11.111.111
    
and the ~/.ssh/known_hosts file looks like

    [11.11.111.111]:2222 ssh-rsa AAAAB...
    github.com,207.97.227.239 ssh-rsa AAAAB...
    user.webfactional.com,22.22.222.222 ssh-rsa AAAAB...
    192.168.1.100 ssh-rsa AAAAB...

Here are some example searches and the search results

 * search-term: **desk**
   1. desktop
   2. desktop1
   
 * search-term: **rv**
   1. vserver
   
 * search-term: **11**
   1. 11.11.111.111:2222
   
 * search-term: **97**
   1. 207.97.227.239
   
 * search-term: **user@** (all hostnames are in the search results)
   1. user@desktop
   2. user@desktop1
   3. user@vserver
   4. user@11.11.111.111:2222
   5. user@github.com
   6. user@207.97.227.239
   7. user@user.webfactional.com
   8. user@22.22.222.222
   9. user@192.168.1.100

 * search-term: **user@des**
   1. user@desktop
   2. user@desktop1

Credits
-------
This lens is based on the gdocs sample lens writen by njpatel which can 
be found on launchpad.
http://bazaar.launchpad.net/~njpatel/unity-lens-gdocs/trunk/files

Dependencies
------------
Introspection data for libunity, libdee, and libdbusmenu-glib

gir1.2-unity-4.0
gir1.2-dee-0.5
gir1.2-dbusmenu-glib-0.4
python-paramiko
python-distutils-extra

Trying out the lens
-------------------

There is no installation script for this so to get Unity to pick
this up you need to:

  sudo mkdir /usr/share/unity/lenses/sshsearch
  sudo cp sshsearch.lens /usr/share/unity/lenses/sshsearch/
  sudo cp unity-lens-sshsearch.png /usr/share/unity/lenses/sshsearch/

Then run the daemon with:

  ./unity-lens-sshsearch.py

And from another terminal restart Unity like this:

  setsid unity

[the setsid ^^ is a small trick to detach the unity process from the terminal
 so you can close it if you want. A bit like 'unity &' just better ;-) ]

Past this step you can freely Control-C the lens daemon to stop it,
do some changes, and restart it. No need to restart Unity, it will find
the newly started daemon automatically.

Getting rid of the Lens
-------------------------------
Just remove the sshsearch.lens file. Fx, by issuing:

  sudo rm /usr/share/unity/lenses/sshsearch/sshsearch.lens

You may want to remove the icon as well, but that's no issue if you don't:

  sudo rm /usr/share/unity/lenses/sshsearch/unity-lens-sshsearch.png

With that done, restart Unity once again with 'setsid unity' and all should
be back to normal.