ssh – remove offending key.

Whenever a system/server is re-installed or the host key changed for any reason, you would have seen the “host key verification failed”. And as usual you would have to go to known_hosts file and delete the offending key. I will show you 2 simple ways to do this here.

The output that you get in such scenario is:

Offending ECDSA key in ~/.ssh/known_hosts:4

First, you can use sed to directly delete the offending key with a command like this :

sed -i 4d ~/.ssh/known_hosts

So, if you see, we are using “-i” to do the changes inline and using “4d” command to delete the 4th line.

But being on Linux has the advantage that everything can be automated. So, lets do this in simpler way.

We will be using command called xclip for this, so get that intalled.

sudo dnf install xclip

Once that is done, add a alias in your bashrc file like this:

alias ssh-remove-key='a=( $(xclip -o|sed "s,:, ,") ) ; sed -i -e "${a[1]}d" ${a[0]}'

After this is done, whenever you get that error, copy the “<file>:line” portion and execute “ssh-remove-key” and the key is gone from file 🙂

Simple rss to email service for your feeds on Linux with your/ISP server.

I like couple of blogs and feeds but the problem is that I keep forgetting to run the rss reader and would rather like to have the rss article\’s emailed to me at regular intervals so that I can read them when I want to without having to make sure that I am at my desktop at home computer or remembering to start the rss client. That sounds simple and do-able so lets try to do that.

First off, there is a rss2email application that you would need to install. If you are on fedora, just do

sudo yum install rss2email

Once that is done, just edit the ~/.rss2email/config.py to specify if you would like to use the sendmail of your system or to use the SMTP server to send the mail.  Here is the config file, how it looks on my system

DEFAULT_FROM=\”mailid\”
HTML_MAIL=1
SMTP_SEND=1
SMTP_SERVER=\”mailserver\”

AUTHREQUIRED=1
SMTP_USER=\”username\”
SMTP_PASS=\”password\”
DATE_HEADER=1

Now we will configure the feeds that we need to receive the email for. So first add the default email address for the program:

r2e email emailaddress

Now is the turn to add the feeds. You can add the feed using the command:

r2e add <URL>

Once that is done, you are ready to go. Just put \”r2e run\” in cron and you start getting the mail without ever forgetting to read the feed or starting the feed client.

But if you have say like 50 odd feeds, then adding then one by one is 🙁

AWK to our rescue here. Take the opml file from your feedreader or bloglines or any other client, doesn\’t matter.

For simplicity sake, assume the file is named export.opml. Then run the following command on a terminal:

awk -F\’=\’ \'{
if ($3 ~ /xmlUrl/)
print$4
if ($4 ~ /xmlUrl/)
print$5
if ($5 ~ /xmlUrl/)
print$6
}\’ export.opml >ak

This will create a file called ak with the URL\’s in the file but contains the \” and some trailing characters, time to remove them and get a shell script that can add the URL\’s for us. AWK to rescue again:

awk -F\”\”\” \'{print \”r2e add \”$2}\’ ak >ak2

This will generate file called ak2, which you can chmod and run to add all the URL\’s to the rss2email program. You can check the handiwork with

r2e list

And if something goes wrong then you can just delete all the feeds, \”r2e list\” note the last number and do the following:

for i in `seq <number> -1 1`; do r2e delete $i; done