aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-02-08 05:07:50 +0000
committerGlenn Morris2008-02-08 05:07:50 +0000
commit9c519cf2a09c560dddb563cc56e0c9f65f158ebe (patch)
tree9da03c02a894ffbde9e5064f0409ccdce706410d
parenta31787b1e9fc5d63511ff7a85f67dbfa22596a9c (diff)
downloademacs-9c519cf2a09c560dddb563cc56e0c9f65f158ebe.tar.gz
emacs-9c519cf2a09c560dddb563cc56e0c9f65f158ebe.zip
Phil Hagelberg <phil at evri.com>
(pcmpl-ssh-known-hosts-file): New defcustom. (pcomplete/ssh, pcomplete/scp, pcmpl-ssh-hosts): New functions.
-rw-r--r--lisp/pcmpl-unix.el49
1 files changed, 49 insertions, 0 deletions
diff --git a/lisp/pcmpl-unix.el b/lisp/pcmpl-unix.el
index f67f1107779..d22e9bdd867 100644
--- a/lisp/pcmpl-unix.el
+++ b/lisp/pcmpl-unix.el
@@ -40,6 +40,11 @@
40 :type 'file 40 :type 'file
41 :group 'pcmpl-unix) 41 :group 'pcmpl-unix)
42 42
43(defcustom pcmpl-ssh-known-hosts-file "~/.ssh/known_hosts"
44 "The location of the user's SSH `known_hosts' file."
45 :type 'file
46 :group 'pcmpl-unix)
47
43;; Functions: 48;; Functions:
44 49
45;;;###autoload 50;;;###autoload
@@ -123,5 +128,49 @@
123 (pcomplete-here* (pcmpl-unix-group-names))) 128 (pcomplete-here* (pcmpl-unix-group-names)))
124 (while (pcomplete-here (pcomplete-entries)))) 129 (while (pcomplete-here (pcomplete-entries))))
125 130
131;; ssh support by Phil Hagelberg.
132;; http://www.emacswiki.org/cgi-bin/wiki/pcmpl-ssh.el
133
134;; This will allow eshell to autocomplete SSH hosts from the list of
135;; known hosts in your ~/.ssh/known_hosts file. Note that newer
136;; versions of ssh hash the hosts by default to prevent Island-hopping
137;; SSH attacks. (https://itso.iu.edu/Hashing_the_OpenSSH_known__hosts_File)
138;; You can disable this by putting the following line in your ~/.ssh/config
139;; file following the "Host *" directive:
140
141;; HashKnownHosts no
142
143;; Note that this will make you vulnerable to the Island-hopping
144;; attack described in the link above if you allow key-based
145;; passwordless logins and your account is compromised.
146
147;;;###autoload
148(defun pcomplete/ssh ()
149 "Completion rules for the `ssh' command."
150 (pcomplete-opt "1246AaCfgKkMNnqsTtVvXxYbcDeFiLlmOopRSw" nil t)
151 (pcomplete-here (pcmpl-ssh-hosts)))
152
153;;;###autoload
154(defun pcomplete/scp ()
155 "Completion rules for the `scp' command.
156
157Includes files as well as host names followed by a colon."
158 (pcomplete-opt "1246BCpqrvcFiloPS")
159 (while t (pcomplete-here (append (pcomplete-all-entries)
160 (mapcar (lambda (host) (concat host ":")) (pcmpl-ssh-hosts))))))
161
162(defun pcmpl-ssh-hosts ()
163 "Returns a list of hosts found in the users `known_hosts' file."
164 (if (file-readable-p pcmpl-ssh-known-hosts-file)
165 (with-temp-buffer
166 (insert-file-contents-literally pcmpl-ssh-known-hosts-file)
167 (let ((ssh-hosts-list) '())
168 (while (not (eobp))
169 (let ((hostname (buffer-substring (point) (- (search-forward-regexp "[, ]") 1))))
170 (unless (string-match "^|" hostname)
171 (add-to-list 'ssh-hosts-list hostname)))
172 (forward-line))
173 ssh-hosts-list))))
174
126;;; arch-tag: 3f9eb5af-7e0e-449d-b586-381cbbf8fc5c 175;;; arch-tag: 3f9eb5af-7e0e-449d-b586-381cbbf8fc5c
127;;; pcmpl-unix.el ends here 176;;; pcmpl-unix.el ends here