domingo, mayo 31, 2015

Get my public IP and send it via email periodically

in order to get the Public IP assigned from your Internet provider to your router, you can use the free service offer by dyndns:

but what if you want to get the ip from console and save this into a text file?, this is usefull if later you wants to send this file to some email. If your need is this, so, just follow the next steps tested in Linux Mint.

first try the command via console and look you get the right answer:

$ curl -s | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'  > mi_ip

this will copy the Public IP to mi_ip file, just check your file and see the result:

$ nano mi_ip

you can add the command to crontab in order to periodically send you an email with the ip result. For this create a shell script:

$ nano

curl -s | sed -e 's/.*Current IP Address: //' -e 's/<.*$//' $
cat ~/mi_ip.txt | mail -s "My IP address is:" put_your_email_here

save and exit nano. Now configure your crontab jobs:

$ crontab -e

put this at the bottom of the file:

#Send mi public ip to my email

save and exit. With the option @daily the scritp would be executed each day at midnight. That's all!

miércoles, mayo 13, 2015

Habilitar servicio Telnet en Ubuntu

1. instalamos los paquetes necesarios:

$ sudo apt-get install xinetd telnetd

2. abrimos el archivo inetd.conf:

$ sudo nano /etc/inetd.conf
colocamos la siguiente línea:

 telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd
3.  editamos el archivo xinetd.conf:

$ sudo nano /etc/xinetd.conf
 colocamos el siguiente contenido:

# Simple configuration file for xinetd
# Some defaults, and include /etc/xinetd.d/
# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30

includedir /etc/xinetd.d

4. verificar en el archivo services que el servicio este en el puerto deseado y si no es así agregarlo:

$ sudo nano /etc/services
telnet        23/tcp
5. si se desea cambiar la configuración del archivo por default podemos crear el archivo telnet:
$ sudo nano etc/xinetd.d/telnet
colocamos el siguiente contenido:

# default: on
# description: The telnet server serves telnet sessions; it uses
# unencrypted username/password pairs for authentication.
service telnet
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID

6. finalmente reiniciamos el servicio:
$ sudo /etc/init.d/xinetd restart