[LUG.ro] E-mail as a System Console. Part I
Alejandro Gomez Fernandez
lugro@lugro.org.ar
Fri, 20 Dec 2002 13:29:14 -0300
This is a multi-part message in MIME format.
--------------030800010109060004050703
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Para aquellos que necesiten administrar un servidor en forma remota, aca
tienen otra posibilidad ...
http://www.linuxjournal.com/article.php?sid=6453
Suena muy interesante, al menos como para verla y tener otra opción. Por
ej, se me esta ocurriendo su aplicación para administrar varios
servidores en forma simultánea ... Seria lindo si funcionase, no?
Avisen si alguno pudo probar esto último ...
Alejandro.
--------------030800010109060004050703
Content-Type: text/html; charset=ISO-8859-1;
name="www.linuxjournal.com/article.php?sid=6453"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;
filename="www.linuxjournal.com/article.php?sid=6453"
Content-Base: "http://www.linuxjournal.com/article.ph
p?sid=6453"
Content-Location: "http://www.linuxjournal.com/article.ph
p?sid=6453"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>E-mail as a System Console. Part I</title>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3DISO-885=
9-1">
<META NAME=3D"AUTHOR" CONTENT=3D"Linux Journal - The Premier Magazine of=
the Linux Community">
<META NAME=3D"COPYRIGHT" CONTENT=3D"Copyright (c) 2002 by Linux Journal =
- The Premier Magazine of the Linux Community">
<META NAME=3D"KEYWORDS" CONTENT=3D"linux, linux journal">
<META NAME=3D"DESCRIPTION" CONTENT=3D"The Monthly Magazine of the Linux C=
ommunity">
<META NAME=3D"GENERATOR" CONTENT=3D"PHP-Nuke 5.0 - http://phpnuke.org">
<LINK REL=3D"StyleSheet" HREF=3D"/themes/NewLJ/style/style.css" TYPE=3D"t=
ext/css">
<SCRIPT type=3D"text/javascript">
<!--
function showimage() {
if (!document.images)
return
document.images.avatar.src=3D
'http://www.linuxjournal.com/images/forum/avatar/' + document.Register.us=
er_avatar.options[document.Register.user_avatar.selectedIndex].value
}
//-->
</SCRIPT>
<script type=3D"text/javascript">
<!--
function openwindow(){
window.open ("","Help","toolbar=3Dno,location=3Dno,directories=3D=
no,status=3Dno,scrollbars=3Dyes,resizable=3Dno,copyhistory=3Dno,width=3D6=
00,height=3D400");
}
//-->
</SCRIPT>
</head>
<body bgcolor=3D"#505050" text=3D"#000000" link=3D"#363636" vlink=3D"#363=
636" alink=3D"#d5ae83">
<table><tr><td>
<center><a href=3D"http://www.linuxjournal.com/banners.php?op=3Dclick&=
;bid=3D159" target=3D"_blank"><img src=3D"http://www.linuxjournal.com/ima=
ges/banners/yosemite/yosemite0807.gif" border=3D"1" height=3D"60" width=3D=
"468" alt=3D""></a></center><br>
<table cellpadding=3D"0" cellspacing=3D"0" width=3D"100%" border=3D"0" al=
ign=3D"center" bgcolor=3D"#ffffff">
<tr>
<td bgcolor=3D"#ffffff">
<img height=3D"16" alt=3D"" hspace=3D"0" src=3D"/themes/NewLJ/images/corn=
er-top-left.png" width=3D"17" align=3D"left">
<a href=3D"/index.php"><img src=3D"/themes/NewLJ/images/logo_blue.png" wi=
dth=3D"147" height=3D"69" align=3D"left" alt=3D"Welcome to Linux Journal =
- The Premier Magazine of the Linux Community" border=3D"0"></a></td>
<td bgcolor=3D"#999999"><IMG src=3D"/themes/NewLJ/images/pixel.gif" width=
=3D"1" height=3D"1" alt=3D"" border=3D"0" hspace=3D"0"></td>
<td bgcolor=3D"#cfcfbb" align=3D"center">
<center><form action=3D"search.php" method=3D"post"><font class=3D"conten=
t" color=3D"#000000"><b>Search </b>
<input type=3D"text" name=3D"query" size=3D"14"></font></form></center></=
td>
<td bgcolor=3D"#cfcfbb" align=3D"center">
<center><form action=3D"search.php" method=3D"get"><font class=3D"content=
"><b>Topics </b>
<select name=3D"topic"onChange=3D'submit()'>
<option value=3D"">All Topics</option>
<option value=3D"11">Book Reviews</option>
<option value=3D"6">Development Tools</option>
<option value=3D"36">Embedded</option>
<option value=3D"17">Games</option>
<option value=3D"34">German</option>
<option value=3D"30">Hardware</option>
<option value=3D"12">Linux Community</option>
<option value=3D"9">Linux in Business</option>
<option value=3D"7">Linux in Education</option>
<option value=3D"29">Linux Journal</option>
<option value=3D"4">Linux Kernel</option>
<option value=3D"21">Linux Market</option>
<option value=3D"1">Miscellaneous</option>
<option value=3D"13">Multimedia</option>
<option value=3D"5">Networking</option>
<option value=3D"31">Other Software</option>
<option value=3D"32">Product of the Day</option>
<option value=3D"19">Product Reviews</option>
<option value=3D"8">Security</option>
<option value=3D"33">Spanish</option>
<option value=3D"35">Tutorial</option>
<option value=3D"28">Web Development</option>
</select></font></form></center></td>
<td bgcolor=3D"#cfcfbb" valign=3D"top"><img height=3D"17" alt=3D"" hspace=
=3D"0" src=3D"/themes/NewLJ/images/corner-top-right.gif" width=3D"17" ali=
gn=3D"right"></td>
</tr></table>
<table cellpadding=3D"0" cellspacing=3D"0" width=3D"100%" border=3D"0" al=
ign=3D"center" bgcolor=3D"#fefefe">
<tr>
<td bgcolor=3D"#000000" colspan=3D"4"><IMG src=3D"/themes/NewLJ/images/pi=
xel.gif" width=3D"1" height=3D1 alt=3D"" border=3D"0" hspace=3D"0"></td>
</tr>
<tr valign=3D"middle" bgcolor=3D"#dedebb">
<td width=3D"15%" nowrap><font class=3D"content" color=3D"#363636"><b>
<!-- BEGIN user customization --> <b><font color=3D"#363636"><=
a href=3D"/user.php">Create</a></font> an account</b>
<!-- END user customization --></b></font></td>
<td align=3D"center" height=3D"20" width=3D"70%"><font class=3D"content">=
<B>
<A href=3D"/">Home</a>
·
<A href=3D"/subscribe.php">Subscribe</a>
·
<A href=3D"/topics.php">Topics</a>
·
<A href=3D"/advertising.php">Advertise</a>
·
<A href=3D"http://pr.linuxjournal.com" target=3D"_blank">Vendor Press</a>=
</B></font>
</td>
<td> </td>
</tr>
<tr>
<td bgcolor=3D"#000000" colspan=3D"4"><IMG src=3D"/themes/NewLJ/images/pi=
xel.gif" width=3D"1" height=3D"1" alt=3D"" border=3D"0" hspace=3D"0"></td=
>
</tr>
</table>
<!-- FIN DEL TITULO -->
<table width=3D"100%" cellpadding=3D"0" cellspacing=3D"0" border=3D"0" bg=
color=3D"#ffffff" align=3D"center"><tr valign=3D"top">
<td bgcolor=3D"#ffffff"><img src=3D"/themes/NewLJ/images/pixel.gif" width=
=3D"1" height=3D"20" border=3D"0" alt=3D""></td></tr></table>
<table width=3D"100%" cellpadding=3D"0" cellspacing=3D"0" border=3D"0" bg=
color=3D"#ffffff" align=3D"center"><tr valign=3D"top">
<td bgcolor=3D"#ffffff"><img src=3D"/themes/NewLJ/images/pixel.gif" width=
=3D"10" height=3D"1" border=3D"0" alt=3D""></td>
<td bgcolor=3D"#ffffff" width=3D"150" valign=3D"top">
<table border=3D"0" cellpadding=3D"1" cellspacing=3D"0" bgcolor=3D"#00000=
0" width=3D"150"><tr><td>
<table border=3D"0" cellpadding=3D"3" cellspacing=3D"0" bgcolor=3D"#dedeb=
b" width=3D"100%"><tr><td align=3Dleft>
<font class=3D"content" color=3D"#363636"><b>Linux Journal</b></font>
</td></tr></table></td></tr></table>
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" bgcolor=3D"#fffff=
f" width=3D"150">
<tr valign=3D"top"><td bgcolor=3D"#ffffff">
<font class=3D"content"><strong><big>=B7</big></strong> <a href=3D"/index=
=2Ephp">Home</a><br>
=20
<strong><big>=B7</big></strong> <a href=3D"/modules.php?op=3Dmodload&name=
=3DNS-subscribe&file=3Dsuboptions#new">Subscribe</a>
/ <a href=3D"/modules.php?op=3Dmodload&name=3DNS-subscribe&file=3Dsubopti=
ons#renew">Renew</a><br>
<strong><big>=B7</big></strong> <a href=3D"/modules.php?op=3Dmodload&nam=
e=3DNS-subscribe&file=3Dsuboptions#address">Change Address</a><br>
<strong><big>=B7</big></strong> <a href=3D"/subscribe.php">Subscriber Ser=
vices</a><br>
<p>
<strong><big>=B7</big></strong> <a href=3D"/advertising.php">Advertise in=
<i>LJ</i></a><br>=20
<strong><big>=B7</big></strong> <a href=3D"/press.php"><i>LJ</i> Press Re=
leases</a><br>
<strong><big>=B7</big></strong> <a href=3D"http://pr.linuxjournal.com" ta=
rget=3D"_blank">Vendor Press Releases</a><br>
<strong><big>=B7</big></strong> <a href=3D"/modules.php?op=3Dmodload&name=
=3DNS-author&file=3Dwanted">Write for Us</a><br>
=20
<strong><big>=B7</big></strong> <a href=3D"/contact.php">Contact Us</a><b=
r><br><b>Other Options</b><br><strong><big>·</big></strong> <=
a href=3D"/modules.php?op=3Dmodload&name=3DFAQ&file=3Dindex">FAQ<=
/a><br><strong><big>·</big></strong> <a href=3D"/modules.php?=
op=3Dmodload&name=3DMembers_List&file=3Dindex">Members List</a><b=
r></font>
</td></tr></table>
<br>
<table border=3D"0" cellpadding=3D"1" cellspacing=3D"0" bgcolor=3D"#00000=
0" width=3D"150"><tr><td>
<table border=3D"0" cellpadding=3D"3" cellspacing=3D"0" bgcolor=3D"#dedeb=
b" width=3D"100%"><tr><td align=3Dleft>
<font class=3D"content" color=3D"#363636"><b>Now Available!</b></font>
</td></tr></table></td></tr></table>
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" bgcolor=3D"#fffff=
f" width=3D"150">
<tr valign=3D"top"><td bgcolor=3D"#ffffff">
<P><center><a href=3D"http://store.linuxjournal.com/Merchant2/merchant.mv=
?Screen=3DPROD&Store_Code=3DLJS&Product_Code=3Dcd2001&Category_Code=3DLA"=
><img src =3D "/images/products/cd2002_115x115.png" height =3D"115" width=
=3D "115"></a></center>
</td></tr></table>
<br>
<table border=3D"0" cellpadding=3D"1" cellspacing=3D"0" bgcolor=3D"#00000=
0" width=3D"150"><tr><td>
<table border=3D"0" cellpadding=3D"3" cellspacing=3D"0" bgcolor=3D"#dedeb=
b" width=3D"100%"><tr><td align=3Dleft>
<font class=3D"content" color=3D"#363636"><b>Experimental</b></font>
</td></tr></table></td></tr></table>
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" bgcolor=3D"#fffff=
f" width=3D"150">
<tr valign=3D"top"><td bgcolor=3D"#ffffff">
<a href=3D"http://blog.linuxjournal.com/">blog.linuxjournal.com</a>
</td></tr></table>
<br>
<table border=3D"0" cellpadding=3D"1" cellspacing=3D"0" bgcolor=3D"#00000=
0" width=3D"150"><tr><td>
<table border=3D"0" cellpadding=3D"3" cellspacing=3D"0" bgcolor=3D"#dedeb=
b" width=3D"100%"><tr><td align=3Dleft>
<font class=3D"content" color=3D"#363636"><b>Linux Resources</b></font>
</td></tr></table></td></tr></table>
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" bgcolor=3D"#fffff=
f" width=3D"150">
<tr valign=3D"top"><td bgcolor=3D"#ffffff">
<strong><big>=B7</big></strong> <a href=3D"/magazine.php">Magazine Archiv=
e</a><br>
<strong><big>=B7</big></strong> <a href=3D"/webindex.php">Web Article Ind=
ex</a><br>
<strong><big>=B7</big></strong> <a href=3D"ftp://ftp.ssc.com/pub/lj/listi=
ngs" target=3D"_blank">Downloads</a><br>
<strong><big>=B7</big></strong> <a href=3D"/resources.php">Linux Resource=
s</a><br>
<strong><big>=B7</big></strong> <a href=3D"/helpdesk.php">SSC Help Desk</=
a><br>
<strong><big>=B7</big></strong> <a href=3D"/newsfeed.php">Referrer News</=
a><br>
<strong><big>=B7</big></strong> <a href=3D"/links.php">Linux Links</a><br=
>
<strong><big>=B7</big></strong> <a href=3D"/cgi-bin/wish/index.pl">Wishli=
st</a><br>
<strong><big>=B7</big></strong> <a href=3D"http://www.ssc.com:8080/glue/"=
target=3D_blank>User Groups (GLUE)</a><br>
<strong><big>=B7</big></strong> <a href=3D"/events.php">Special Events</a=
><br>
</td></tr></table>
<br>
<table border=3D"0" cellpadding=3D"1" cellspacing=3D"0" bgcolor=3D"#00000=
0" width=3D"150"><tr><td>
<table border=3D"0" cellpadding=3D"3" cellspacing=3D"0" bgcolor=3D"#dedeb=
b" width=3D"100%"><tr><td align=3Dleft>
<font class=3D"content" color=3D"#363636"><b>Store</b></font>
</td></tr></table></td></tr></table>
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" bgcolor=3D"#fffff=
f" width=3D"150">
<tr valign=3D"top"><td bgcolor=3D"#ffffff">
<strong><big>=B7</big></strong> <a href=3D"http://store.linuxjournal.com/=
Merchant2/merchant.mv?Screen=3DPROD&Store_Code=3DLJS&Product_Code=3DLJA&C=
ategory_Code=3DLA" target=3D"_blank">Order Back Issues</a><br>
<strong><big>=B7</big></strong> <a href=3D"http://store.linuxjournal.com/=
Merchant2/merchant.mv?Screen=3DCTGY&Store_Code=3DLJS&Category_Code=3DT" t=
arget=3D"_blank">T-shirts</a><br>=20
<strong><big>=B7</big></strong> <a href=3D"http://store.linuxjournal.com/=
Merchant2/merchant.mv?Screen=3DCTGY&Store_Code=3DLJS&Category_Code=3DH" t=
arget=3D"_blank">Hats</a><br>=20
<strong><big>=B7</big></strong> <a href=3D"http://store.linuxjournal.com/=
Merchant2/merchant.mv?Screen=3DCTGY&Store_Code=3DLJS&Category_Code=3DRC" =
target=3D"_blank">Reference Cards</a><br>=20
<strong><big>=B7</big></strong> <a href=3D"http://store.linuxjournal.com/=
Merchant2/merchant.mv?Screen=3DCTGY&Store_Code=3DLJS&Category_Code=3DB" t=
arget=3D"_blank">Books</a><br>=20
<strong><big>=B7</big></strong> <a href=3D"http://store.linuxjournal.com"=
target=3D"_blank">Fun Stuff</a><br>
</td></tr></table>
<br>
<table border=3D"0" cellpadding=3D"1" cellspacing=3D"0" bgcolor=3D"#00000=
0" width=3D"150"><tr><td>
<table border=3D"0" cellpadding=3D"3" cellspacing=3D"0" bgcolor=3D"#dedeb=
b" width=3D"100%"><tr><td align=3Dleft>
<font class=3D"content" color=3D"#363636"><b>Kernel Watch</b></font>
</td></tr></table></td></tr></table>
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" bgcolor=3D"#fffff=
f" width=3D"150">
<tr valign=3D"top"><td bgcolor=3D"#ffffff">
<STRONG>Nuts</STRONG> <A HREF=3D"http://www.kernel.org/pub/lin=
ux/kernel/v2.5" TARGET=3D"_blank">2.5.52</A>
<br>15-Dec-2002
<br><STRONG>Sane</STRONG> <A HREF=3D"http://www.kernel.org/pub=
/linux/kernel/v2.4" TARGET=3D"_blank">2.4.20</A>
<br>28-Nov-2002
<br><STRONG>Safe</STRONG> <A HREF=3D"http://www.kernel.org/pub=
/linux/kernel/v2.2" TARGET=3D"_blank">2.2.23</A>
<br>29-Nov-2002
<br><A HREF=3D"http://www.kernel.org" TARGET=3D"_blank">Archives</A>
</td></tr></table>
<br>
<table border=3D"0" cellpadding=3D"1" cellspacing=3D"0" bgcolor=3D"#00000=
0" width=3D"150"><tr><td>
<table border=3D"0" cellpadding=3D"3" cellspacing=3D"0" bgcolor=3D"#dedeb=
b" width=3D"100%"><tr><td align=3Dleft>
<font class=3D"content" color=3D"#363636"><b>Other SSC Sites</b></font>
</td></tr></table></td></tr></table>
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" bgcolor=3D"#fffff=
f" width=3D"150">
<tr valign=3D"top"><td bgcolor=3D"#ffffff">
<strong><big>=B7</big></strong> <a href=3D"http://www.eljonline.com" targ=
et=3D"_blank">Embedded Linux Journal</a><br>
<strong><big>=B7</big></strong> <a href=3D"http://www.linuxgazette.com" t=
arget=3D"_blank">Linux Gazette</a><br>
<strong><big>=B7</big></strong> <a href=3D"http://www.linuxjournal.com/bg=
" >Linux Buyer's Guide</a><br>
<strong><big>=B7</big></strong> <a href=3D"http://pr.linuxjournal.com" ta=
rget=3D"_blank">pr.linuxjournal.com</a><br>
<strong><big>=B7</big></strong> <a href=3D"http://www.ssc.com" target=3D"=
_blank">SSC</a><br>
</td></tr></table>
<br>
</td><td><img src=3D"/themes/NewLJ/images/pixel.gif" width=3D"15" height=3D=
"1" border=3D"0" alt=3D""></td><td width=3D"100%">
<!-- END HEADER -->
<table width=3D"100%" border=3D"0"><tr><td valign=3D"top">
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" bgcolor=3D"#fffff=
f" width=3D"100%"><tr><td>
<table border=3D"0" cellpadding=3D"1" cellspacing=3D"0" bgcolor=3D"#00000=
0" width=3D"100%"><tr><td>
<table border=3D"0" cellpadding=3D"3" cellspacing=3D"0" bgcolor=3D"#cfcfb=
b" width=3D"100%"><tr><td align=3D"left">
<font class=3D"option" color=3D"#363636"><b><a href=3D"categories.php?op=3D=
newindex&catid=3D36">HOWTO</a>: <font color=3D"navy">E-mail as a Syst=
em Console. Part I</font></b></font><br>
<font class=3D"content">Posted on Wednesday, November 20, 2002 by <a href=
=3D"mailto:mtl@multitool.net">Michael Schwarz, Jeremy Anderson, Peter Cur=
tis and Steve Murphy</a></td><td align=3D"right"><a href=3D"print.php?sid=
=3D6453"><img src=3D"/images/print2.png" border=3D0 Alt=3D"Printer Friend=
ly Page" width=3D"15" height=3D"11"></a> <a href=3D"friend.php=
?op=3DFriendSend&sid=3D6453"><img src=3D"/images/friend.png" border=3D=
"0" Alt=3D"Send this Article to a Friend" width=3D"15" height=3D"11"></a>=
</td></tr></table></td></tr></table><br><a href=3D"search.php?query=3D&am=
p;topic=3D5"><img src=3D"/images/topics/networking2.png" border=3D"0" Alt=
=3D"Networking" align=3D"right" hspace=3D"10" vspace=3D"10"></a>
<font class=3D"content" color=3D"#000000"><i>Accessing your home system f=
rom work or from around the world, using fetchmail, procmail and a few sc=
ripts.</i><br><br><P>
<img align=3D"right" src=3D"/modules/NS-articles/HOWTO/6453f1.jpg">
<P>
<I>Editors' Note: The following is a chapter from the book Multitool Linu=
x,
written by Michael Schwarz, Jeremy Anderson, Peter Curtis and
Steven Murphy. Consult the=20
<a href=3D"http://www.multitool.net/mtl/" target=3D"_blank">book's web si=
te</a>=20
for links, updates and errata.</i>
<P>
Question: How can I get access to my home Linux system when I'm 1)at work=
behind a firewall that only allows me to send e-mail from my workstation
or 2)away on a business trip and the hotel firewall only allows me to
surf the Web?
<P>
Answer: Create an e-mail-based console application that let's you execute=
commands and return results via e-mail. If you're stuck with only web acc=
ess,
get a web e-mail account somewhere and use it to send commands over e-mai=
l to
your system at home. The e-mail console is a nice way to communicate with=
your
system when normal communications (Telnet, ssh, FTP, what-have-you) are n=
ot
available.
<P>
Have you ever been sitting around at work and wished you could execute a
command on your home Linux system to find some information? I have and
I bet you could find lots of reasons why you would want to do this as wel=
l.
E-mail is simple, yet powerful. But can it be used as a console to your h=
ome
Linux system? You bet! I use it all the time.=20
<P>
But why not just log in and execute commands in the traditional manner? S=
ure, I could do that, but that would be no
fun. In addition, there are times when direct access to a system is
not available. But if e-mail is available, then this e-mail console
application will work for you. First,
I'll tell you about how I arrived at developing the e-mail console, then =
I'll
share how I did it.
<P>
<h3>My Disconnected System</h3>
<P>
If you're like me, at one time you probably connected to the Internet usi=
ng a
standard phone line and a local ISP. I like my ISP,=20
but they limit the number of hours I can be on-line each month and charge=
me big
bucks when I go over that limit. I won't switch ISP's because they are, w=
ithout a
doubt, the best in my area. Because of this restriction to my on-line
adventures, I pick and choose the times when my Linux system will be on-l=
ine
fetching e-mail, downloading files and so forth. The problem I have with =
this
situation is I want access to my home system when I am at work.
And when I'm at work, I often find myself needing to access my home syste=
m to get a
file. With my monthly limit, I can't simply leave my computer continuousl=
y
connected to the Internet during the day. What I need is a way to
keep my home system off-line until I need it and then have it go on-line =
and
stay that way until I tell it to disconnect.
<P>
Some time ago I decided to make it so my system would periodically connec=
t to
the Internet and download e-mail from my ISP using a nifty program called=
fetchmail. I wrote a few Perl scripts to automate and synchronize the
connection requests from various applications, including SETI@HOME and
fetchmail, which both need to connect to the Internet at various times. P=
lus, I needed to
go on-line to surf around but not get disconnected when the fetchmail uti=
lity
completed its work. Getting e-mail with fetchmail allows me to spend as l=
ittle
connection time as possible getting and responding to e-mail--why waste c=
onnection=20
time typing replies?=20
<P>
The main goal of these scripts is to
coordinate the connection and disconnection requests and keep my system
on-line when needed. It then occurred to me that if I could somehow send =
an e-mail to my
system (which picked up e-mail once an hour) and somehow have that e-mail=
parsed,
so a command could be executed, I could tell my system to stay on-line or=
disconnect. Bingo! Now all I had to do was
find that e-mail parsing, command-executing, dream utility. The solution =
was
right under my keyboard.
<P>
<h3>Getting Connected</h3>
<P>
On a piece of paper beneath my keyboard was a list of utilities I thought=
might=20
be useful for dealing with my e-mail; procmail was
one of them. Procmail, as it turns out, is an incredibly useful utility f=
or performing
searches on incoming e-mail and then performing some kind of action.
Currently, I use procmail to parse my incoming e-mail every 15 minutes (I=
changed it from an hour down to 15 minutes so I wouldn't
have to wait so long to access my system). It executes the command that
tells my system to stay on-line after it is done
fetching e-mail. Now, I can send e-mail to my home system
with a special subject like "CONNECT REMOTE", and my system will simply s=
tay
on-line after fetching and processing all the e-mail from my ISP. In my p=
rocmail
configuration file, a recipe file, I searched for this string and then ex=
ecuted
the Perl script I had written to make it so my system stayed on-line. I c=
ould
also tell it to disconnect. Once I had this set up, it occurred to me tha=
t with a little more
work, I could write a procmail recipe and Perl script that would execute =
any
arbitrary command I gave it. This was the coolest thing I had ever heard
of, and my "e;NT"e; friends would be so jealous!
<P>
<h3>Locking It Down</h3>
<P>
Because anyone can send me an e-mail, I had to work out a protocol that w=
ould
allow me and trusted friends but no one else to execute commands. I also
needed to ensure that the results were returned securely, safe from snoop=
ing eyes. The
solution to all of this lies with encryption and digital signatures found=
in
another great utility, GnuPG.
<P>
<h3>The Project</h3>
<P>
Now that you know the story of how the e-mail console came to be, it's ti=
me to
put together all the pieces and make a working system. The following
utilities are necessary for this project:
<P>
<ul>
<li>fetchmail - to get the mail
<li>procmail - to parse and execute the e-mail console script
<li>GnuPG - to decrypt the e-mail and verify the authenticity of the =
sender
</ul>
<P>
<h3>The Disclaimer</h3>
<P>
Doing this project could seriously damage your system. If you implement t=
his
project, anyone--and I mean anyone--on the planet with Internet access an=
d an
e-mail account has the potential to be able to execute any command--even
as root--on your system. Please, do not attempt this project if you are n=
ot 100%
sure you can secure your system from unauthorized use. In plain English,
don't do this project unless you know what you are doing, and don't blame=
me if
you screw it up and get your system hacked. I warned you. You know what? =
Just
don't do it. Just read the [article] and learn. But don't do it.=20
Imagine logging in one day to discover your hard disk has=20
been wiped clean by some hacker who discovered he could send a simple e-m=
ail=20
containing a few simple commands to your system. You have
been warned: do this project at your own risk.=20
<P>
<h3>Understanding E-mail</h3>
<P>
E-mail comes in; e-mail goes out. Simple, right? Ah, not so my friend. Yo=
ur e-mail
requirements and my e-mail requirements are probably different. With this=
in
mind, I'm going to take the easy way out and describe my e-mail setup.
You cane work out for yourself how to adapt the e-mail console for your
e-mail setup.
<P>
I use Exim as my mail delivery agent (MDA). This delivers incoming mail t=
o my
personal mail folder/file. On a side note, a mail transport agent (MTA)
delivers mail between connected mail hosts. On yet another side note, a m=
ail
user agent (MUA) is the e-mail client program you use to read and send e-=
mail
with. A lot of Linux distributions use sendmail as their MDA.
<P>
Whatever works for you should be fine. The key thing to remember is when
using a MDA, local e-mail is delivered to your e-mail file, which is usua=
lly /var/
mail/your_account. Some Linux distributions might differ on this configur=
ation.
I'm going to assume you don't receive e-mail directly from the Internet b=
ut
instead use an ISP to store e-mail for you. If you are set up with a DNS,=
a
static IP and have direct Internet e-mail capabilities, stop reading=20
because you probably know more about e-mail systems than I do.
<P>
When e-mail is waiting at your ISP, you have basically two ways to
retrieve it. The first is to use a client e-mail program like KMail or Ne=
tscape Mail and retrieve
your e-mail via POP or IMAP. The second option is to use fetchmail,
which also uses POP or IMAP. It delivers your e-mail to your MDA, which
then delivers the e-mail to your local account's mailbox (/var/mail/you_a=
ccount).
There are other ways to get your e-mail, but they are not relevant to thi=
s
discussion.
<P>
Once the e-mail is in /var/local/your_account, you can use almost any e-m=
ail
client to retrieve it. This usually means transferring the e-mail to anot=
her
folder in your home folder, .mail or Mail, or some other location.
<P>
In Part II we'll talk about fetchmail, procmail and how to make them work=
together.
<P>
Copyright 2002 by Addison-Wesley. All rights reserved. Reproduced by
permission of Pearson Education, Inc.=20
<P><br><br><center><a href=3D"https://www.ssc.com/cgi-bin/lj/subbanana.py=
?form=3DNewUSA&article=3D6453"><img src=3D"/images/ljsubsbutton.png" heig=
ht=3D"88" width=3D"90"></a></center></font>
</td></tr></table><br>
</td></tr></table>
<!-- COMMENTS NAVIGATION BAR START -->
<a name=3D"comments"></a>
<table width=3D"99%" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
<tr><td bgcolor=3D"#cfcfbb" align=3D"center"><font class=3D"content" colo=
r=3D"#000000">"E-mail as a System Console. Part I" | <a href=3D"user.php"=
><font color=3D"#000000">Login/Create an Account</font></a> | <B>3</B> co=
mments</font></td></tr>
<tr><td bgcolor=3D"#efefef" align=3D"center" width=3D"100%">
<table border=3D"0"><tr><td><font class=3D"content">
<form method=3D"get" action=3D"article.php">
<font color=3D"#000000">Threshold</font> <select name=3D"thold">
<option value=3D"-1">-1</option>
<option value=3D"0" selected>0</option>
<option value=3D"1">1</option>
<option value=3D"2">2</option>
<option value=3D"3">3</option>
<option value=3D"4">4</option>
<option value=3D"5">5</option>
</select> <select name=3Dmode><option value=3D"nocomments">No Comments</o=
ption>
<option value=3D"nested">Nested</option>
<option value=3D"flat">Flat</option>
<option value=3D"thread" selected>Thread</option>
</select> <select name=3D"order"><option value=3D"0" selected>Oldest Firs=
t</option>
<option value=3D"1">Newest First</option>
<option value=3D"2">Highest Scores First</option>
</select>
<input type=3D"hidden" name=3D"sid" value=3D"6453">
<input type=3D"submit" value=3D"Refresh"></form>
</font></td><td bgcolor=3D"#efefef"><font class=3D"content"><form action=3D=
"comments.php" method=3D"post"><input type=3D"hidden" name=3D"pid" value=3D=
""><input type=3D"hidden" name=3D"sid" value=3D"6453"><input type=3D"hidd=
en" name=3D"op" value=3D"Reply"> <input type=3D"submit" value=3D=
"Post Comment"></form></font></td></tr></table>
</td></tr><tr><td bgcolor=3D"#cfcfbb" align=3D"center"><font class=3D"tin=
y">The comments are owned by the poster. We aren't responsible for their =
content.</font></td></tr>
</table>
<!-- COMMENTS NAVIGATION BAR END -->
<a name=3D"5001"></a><table width=3D"99%" border=3D"0"><tr bgcolor=3D"#ef=
efef"><td width=3D"500"><b>Re: E-mail as a System Console. Part I</b> <fo=
nt class=3D"content">(Score: 0)<br>by Anonymous on Friday, November 22, 2=
002</font></td></tr><tr><td><p>
There is an application I've written which is similiar to the one propose=
d. I call it <b>SMSTerm</b>. Only that it works over SMS. So, you can do =
it all by using a cell phone. It uses the ICQ protocol for sending/receiv=
ing the SMS. Its in use for quite a few months now. I dont have a webpage=
or anything for it, since I'm in my final year of my engineering, and I =
dont have the time to put anything up. The source is under the GPL. You c=
an view the project record at:
</p>
<a href=3D"http://freshmeat.net/projects/smsterm">http://freshmeat.net/pr=
ojects/smsterm
</a>
<p>
I wanted to do this when I wanted to manage a few servers at college whil=
e in class. :)
</p>
<p>
SMS is very cheap here (India) and there is considerable proliferation of=
GSM phones <br><br><b><a href=3D"comments.php?sid=3D6453&tid=3D5001&mode=
=3D&order=3D&thold=3D">Read the rest of this comment...</a></b></td></tr>=
</table><br><br><font class=3D"content"> [ <a href=3D"comments.php?op=3DR=
eply&pid=3D5001&sid=3D6453&mode=3D&order=3D&thold=3D"=
>Reply to This</a> ]</font><br><br></ul><a name=3D"5045"></a><table width=
=3D"99%" border=3D"0"><tr bgcolor=3D"#efefef"><td width=3D"500"><b>Securi=
ty Suggestion</b> <font class=3D"content">(Score: 0)<br>by Anonymous on T=
hursday, November 28, 2002</font></td></tr><tr><td>Talking about the secu=
rity of the above suggested system, I've just had an ideea after reading =
the article. How about configuring procmail so that it will only accept a=
nd pass on shell commands from a particular e-mail address (such as your =
remote one), instead parsing and accepting commands from any e-mail addre=
ss. Or, how about changing the Perl script to send the replies to the she=
ll commands only to a certain address (again, the remote admin address), =
or both of these solutions in the same time?
<br />
<br />
That should add some extra security, in the sense that it will make it mo=
re difficult for people to just send in an e-mail with the commands in th=
e subject/header.</td></tr></table><br><br><font class=3D"content"> [ <a =
href=3D"comments.php?op=3DReply&pid=3D5045&sid=3D6453&mode=3D=
&order=3D&thold=3D">Reply to This</a> ]</font><br><br><ul><li><fo=
nt class=3D"content" color=3D"#000000"><a href=3D"comments.php?op=3Dshowr=
eply&tid=3D5315&sid=3D6453&pid=3D5045&mode=3D&order=3D=
&thold=3D#5315">Re: Security Suggestion</a> by Anonymous on Monday, D=
ecember 16, 2002</font><br></ul><!-- Finished article caching (or not cac=
hing). --></td><td bgcolor=3D"#ffffff"><img src=3D"/themes/NewLJ/images/p=
ixel.gif" width=3D10 height=3D1 border=3D0 alt=3D"">
</td></tr></table>
<table width=3D"100%" cellpadding=3D"0" cellspacing=3D"0" border=3D"0" bg=
color=3D"#ffffff" align=3D"center"><tr valign=3D"top">
<td align=3D"center" height=3D"17">
<IMG height=3D"17" alt=3D"" hspace=3D"0" src=3D"/themes/NewLJ/images/corn=
er-bottom-left.png" width=3D"17" align=3D"left">
<IMG height=3D"17" alt=3D"" hspace=3D"0" src=3D"/themes/NewLJ/images/corn=
er-bottom-right.png" width=3D"17" align=3D"right">
</td></tr></table>
<br><table width=3D"100%" cellpadding=3D"0" cellspacing=3D"0" border=3D"0=
" bgcolor=3D"#ffffff" align=3D"center"><tr valign=3D"top">
<td><IMG height=3D"17" alt=3D"" hspace=3D"0" src=3D"/themes/NewLJ/images/=
corner-top-left.png" width=3D"17" align=3D"left"></td>
<td width=3D"100%"> </td>
<td><IMG height=3D"17" alt=3D"" hspace=3D"0" src=3D"/themes/NewLJ/images/=
corner-top-right.gif" width=3D"17" align=3D"right"></td>
</tr><tr align=3D"center">
<td width=3D"100%" colspan=3D"3">
<!-- BEGIN FOOTER -->
<center><font class=3Dtiny>
<a href=3D"http://www.ssc.com" target=3D"blank"><img src=3D"/images/s=
sc_logo.png" border=3D0></a> <br>
=A9 1994-2002 Specialized Systems Consultants, Inc. (SSC) publishers =
of <i>Linux Journal</i>. <br>
<center> <a href=3D"http://www.ssc.com/ssc/privacy.html">Privacy Stat=
ement</a> </center><br>
Syndicated news file: <a href=3D"/news.rss">news.rss</a><br>Powered b=
y <a href=3D"http://phpnuke.org" target=3D"_blank">PHP-Nuke</a> <br>
</font></center>
</td>
</tr><tr>
<td><IMG height=3D"17" alt=3D"" hspace=3D"0" src=3D"/themes/NewLJ/images/=
corner-bottom-left.png" width=3D"17" align=3D"left"></td>
<td width=3D"100%"> </td>
<td><IMG height=3D"17" alt=3D"" hspace=3D"0" src=3D"/themes/NewLJ/images/=
corner-bottom-right.png" width=3D"17" align=3D"right"></td>
</tr></table>
</TD></TR></TABLE>
</body>
</html>
--------------030800010109060004050703--