From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Phil Hagelberg Newsgroups: gmane.emacs.devel Subject: Re: Pcompletion for ssh and scp Date: Thu, 06 Dec 2007 09:46:01 -0800 Message-ID: <85tzmvaf8m.fsf@evri.com> References: <85d4tmm6pc.fsf@evri.com> <85zlwolwwy.fsf@evri.com> <5y63zcsn2f.fsf@fencepost.gnu.org> <85fxygborx.fsf@evri.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1196963219 5160 80.91.229.12 (6 Dec 2007 17:46:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 6 Dec 2007 17:46:59 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 06 18:47:07 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1J0KoF-0001sP-Oq for ged-emacs-devel@m.gmane.org; Thu, 06 Dec 2007 18:46:52 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J0Kny-0004ZF-Tr for ged-emacs-devel@m.gmane.org; Thu, 06 Dec 2007 12:46:34 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J0KnW-00040g-OI for emacs-devel@gnu.org; Thu, 06 Dec 2007 12:46:06 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J0KnW-0003zU-4C for emacs-devel@gnu.org; Thu, 06 Dec 2007 12:46:06 -0500 Original-Received: from dsl017-040-092.sea1.dsl.speakeasy.net ([69.17.40.92] helo=zimbra.evri.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J0KnV-0005LZ-I4; Thu, 06 Dec 2007 12:46:05 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.evri.com (Postfix) with ESMTP id 36E8024CB4; Thu, 6 Dec 2007 09:45:18 -0800 (PST) X-Virus-Scanned: amavisd-new at X-Spam-Score: -2.509 Original-Received: from zimbra.evri.com ([127.0.0.1]) by localhost (zimbra.evri.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fLOJpShWl+4S; Thu, 6 Dec 2007 09:45:15 -0800 (PST) Original-Received: from imp (dsl017-040-082.sea1.dsl.speakeasy.net [69.17.40.82]) by zimbra.evri.com (Postfix) with ESMTP id B42E7B2FF; Thu, 6 Dec 2007 09:45:15 -0800 (PST) In-Reply-To: (Glenn Morris's message of "Wed, 05 Dec 2007 21:22:15 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:84803 Archived-At: --=-=-= Glenn Morris writes: > Phil Hagelberg wrote: > >> The attached version limits to hostnames that don't start with "|". > > I see no attachment here. Indeed, I must be losing it. This time it's for real. -Phil --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=pcmpl-ssh.el Content-Transfer-Encoding: quoted-printable ;;; pcmpl-ssh.el --- functions for completing SSH hostnames ;; Copyright (C) 2007 Phil Hagelberg ;; Author: Phil Hagelberg ;; URL: http://www.emacswiki.org/cgi-bin/wiki/pcmpl-ssh.el ;; Version: 0.2 ;; Created: 2007-12-02 ;; Keywords: shell completion ssh ;; EmacsWiki: PcompleteSSH ;; This file is NOT part of GNU Emacs. ;; Last-Updated: Sun Dec 04 11:51:06 2007 PST ;; By: Phil Hagelberg ;; Update #: 2 ;;; License: ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; This will allow eshell to autocomplete SSH hosts from the list of ;; known hosts in your ~/.ssh/known_hosts file. Note that newer ;; versions of ssh hash the hosts by default to prevent Island-hopping ;; SSH attacks. (https://itso.iu.edu/Hashing_the_OpenSSH_known__hosts_File) ;; You can disable this by putting the following line in your ~/.ssh/config ;; file following the "Host *" directive: ;; HashKnownHosts no ;; Note that this will make you vulnerable to the Island-hopping ;; attack described in the link above if you allow key-based ;; passwordless logins and your account is compromised. ;;; Code: (require 'pcomplete) (require 'executable) (defcustom pcmpl-ssh-known-hosts-file "~/.ssh/known_hosts" "The location of the user's SSH `known_hosts' file." :type 'file :group 'pcmpl) ;;;###autoload (defun pcomplete/ssh () "Completion rules for the `ssh' command." (pcomplete-opt "1246AaCfgKkMNnqsTtVvXxYbcDeFiLlmOopRSw" nil t) (pcomplete-here (pcmpl-ssh-hosts))) ;;;###autoload (defun pcomplete/scp () "Completion rules for the `scp' command. Includes files as well as host names followed by a colon." (pcomplete-opt "1246BCpqrvcFiloPS") (while t (pcomplete-here (append (pcomplete-all-entries) (mapcar (lambda (host) (concat host ":")= ) (pcmpl-ssh-hosts)))))) (defun pcmpl-ssh-hosts () "Returns a list of hosts found in the users `known_hosts' file." (if (file-readable-p pcmpl-ssh-known-hosts-file) (with-temp-buffer (insert-file-contents-literally pcmpl-ssh-known-hosts-file) (let ((ssh-hosts-list) '()) (while (not (eobp)) (let ((hostname (buffer-substring (point) (- (search-forward-re= gexp "[, ]") 1)))) (unless (string-match "^|" hostname) (add-to-list 'ssh-hosts-list hostname))) (forward-line)) ssh-hosts-list)))) (provide 'pcmpl-ssh) ;;; pcmpl-ssh.el ends here --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--