LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 04-17-2008, 02:45 PM   #1
corrosivemisery
LQ Newbie
 
Registered: Jul 2007
Posts: 19

Rep: Reputation: 9
Question SSH - known_hosts ... Quick editing tools available?


I'm hitting up the LQ community with a question on how to simplify an annoyance.

Question is...are there any tools in existence command line or GUI that can allow you to quick edit your ~/.ssh/known_hosts file? I'd like something that perhaps lists the IP/URL and allows you to just click and delete or pass the IP/URL to a command line util for deletion.

It'd be handy to have for DHCP environments where the ip address/key pair frequently changes.

-Corr
 
Old 04-17-2008, 06:30 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,561
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
Code:
function ssh_knownhosts_cfg() { # Edit your ~/.ssh/known_hosts
 function __opsEnabled() { # Work on enabled hosts
  enabled=`awk -F' |,' '/^[0-9,a-z,A-Z]/ {print $1}' .ssh/known_hosts`
  select host in menu $enabled ; do [ "$host" == "menu" ] && break
   echo "sed -i \"s|$host|#$host|g\" ~/.ssh/known_hosts"; break
   done; } # end __opsEnabled
 function __opsDisabled() { # Work on disabled hosts
  disabled=`awk -F' |,' '/^#/ {print $1}' .ssh/known_hosts`
  select host in menu $disabled ; do [ "$host" == "menu" ] && break
   echo "sed -i \"s|$host|${host#\#}|g\" ~/.ssh/known_hosts"; break
  done; } # end __opsDisabled
 select type in enabled disabled quit; do
  case "$type" in enabled) __opsEnabled;; disabled) __opsDisabled;;
  quit) return 0;; esac; echo -en "1) enabled\n2) disabled\n3) quit\n"
done; } # end ssh_knownhosts_cfg
- This kludge works only with shells that can handle it and if your known_hosts is at ~/.ssh/known_hosts.
- This can only disable enabled hosts and enable disabled hosts.
- This should cover host lines with and without options.
- Check if my 'awk' and 'sed' needs improvement.
- Remove the echo and escapes from the sed lines.
- Add to your ~/.bashrc (or source a separate alias library, I do).
- Backup your ~/.ssh/known_hosts and don't tell me I didn't warn you.
- Type 'ssh_knownhosts_cfg' to run it.
- If it nukes your known_hosts file or your box you keep the fallout.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
search quick download tools linwenyuan Linux - Desktop 6 09-23-2006 12:29 PM
Level editing tools GameMaker Linux - Games 1 02-07-2006 05:27 PM
ssh known_hosts question lthaus Linux - Security 1 12-08-2004 10:07 PM
Audio Editing and Video capture tools... redrobin77 Suse/Novell 2 11-25-2004 07:58 AM
Image Editing Tools Suggestions Please tiredoflogins Linux - Software 14 11-07-2004 12:46 PM


All times are GMT -5. The time now is 12:35 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration