Tuesday, October 17, 2017

Send email using TELNET and Sendmail protocols

Send Email Using Telnet 

Note : We use the domain mailserver.co.in as an example. Be sure to replace with your own domain.
  • Open your command prompt.
  • Now, connect with telnet using the following command:
telnet mailserver.co.in 25

  • Type ehlo example.com. Some servers also accept helo in place of ehlo.

ehlo 
mailserver.co.in


  • Type mail from: sender@mailserver.co.in:


mail from: sender@mailserver.co.in


  • Type rcpt to: receiver@anydomain.com (replace with your actual recipient name):


rcpt to: 
receiver@anydomain.com


  • To write the message - type data, followed by your subject and message. To end the message, put a period on a line by itself and press enter:


data
Subject: My Telnet Test Email
Hello,
This is an email sent by Minder server using the telnet command.
Your friend,
Me
.


Type quit to 
exit telnet.


Now you should receive Test email sender@mailserver.co.in to receiver@anydomain.com

SSH Password less Login Using SSH Keygen

To configure SSH Passwordless Login Using SSH Keygen.
Find My Scenario to configure.

SSH Client : 192.168.1.193 ( CentOS 7 )
SSH Remote Host : 192.168.1.47 ( CentOS 7 )
Step 1: Create Authentication SSH-Kegen Keys on – (192.168.1.193 – Client)

First login into server 192.168.1.193 with user root and generate a pair of public keys using following command.

[root@gcdc-nms opt]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/rsync_key
Enter passphrase (empty for no passphrase): [Hit Enter]
Enter same passphrase again: [Hit Enter]
Your identification has been saved in /root/.ssh/rsync_key.
Your public key has been saved in /root/.ssh/rsync_key.pub.
The key fingerprint is:
SHA256:9hAlaN2gBCOmbIVv4QcGOiMSZp9yIHcVFgeWvHizo/4 root@gcdc-nms.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|o=*.++OB+o.      |
|**+*.==o.o.      |
|B+++oo...        |
|+oo+..+  .       |
|  . .. oS        |
|      o. o       |
|     . .  .      |
|    .            |
|   ...E          |
+----[SHA256]-----+


Step 2: Create .ssh Directory on – 192.168.1.47 (Server)

# ssh root@192.168.1.47 mkdir -p .ssh

Step 3: Upload Generated Public Keys to – 192.168.1.47 (Go to 192.168.1.193 – Client)

# cat .ssh/id_rsa.pub | ssh root@192.168.1.47 'cat >> .ssh/authorized_keys'

Step 4: Set Permissions on – 192.168.1.47 (Server)

# ssh root@192.168.1.47 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

Step 5: Login from 192.168.1.193 (Client) to 192.168.1.47 (Server) Server without Password

# ssh root@192.168.1.47

How to enable JMX console on Apache Tomcat 7.x.x

First Stop tomcat service if it is running. Navigate to tomcat home directory.

 #cd /opt/tomcat/bin
 #./shutdown.sh
Now create setenv.sh file at /opt/tomcat/bin and put below entry in file (setenv.sh).

#vim setenv.sh

CATALINA_OPTS="-Dcom.sun.management.jmxremote.port=8090 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.1.150"







Note :- Here this will allow JMX to connect on 8090 port number, without authentication. An server hostname or ip address is 192.168.1.150
Now start tomcat service by running below command.
#cd /opt/tomcat/bin
#chmod 775 setenv.sh
#sh startup.sh





It should be run without any errors like shown above, check port number is in listening state or not.





Now connect from server from JAVA monitoring console to verify.























Click on connect, it will prompt for insecure connection, click on Insecure connection.










Now You will see device details on console after successfully connection established.

























Installing the SNMP Service

  1. Log in as root user and right click anywhere on the desktop then, click on Open Terminal.
  2. To verify if the SNMP package is installed, there are few ways:
[root@localhost ~]# rpm -qa | grepsnmp
[root@localhost ~]# snmpwalk
-bash: snmpwalk: command not found
[root@localhost ~]# ls /etc/snmp*
ls: /etc/snmp*: No such file or directory
This mean net-snmp package is not installed yet.

  • Install net-snmp & net-snmp-utils package via yum or up2date
CentOS/Fedora:

[root@localhost ~]# yum install net-snmp net-snmp-utils
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.usonyx.net
* extras: mirror.usonyx.net
* updates: mirror.usonyx.net
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package net-snmp.i386 1:5.3.2.2-17.el5_8.1 set to be updated
–> Processing Dependency: libsensors.so.3 for package: net-snmp
—> Package net-snmp-utils.i386 1:5.3.2.2-17.el5_8.1 set to be updated
–> Running transaction check
—> Package lm_sensors.i386 0:2.10.7-9.el5 set to be updated
–> Finished Dependency Resolution
Dependencies Resolved
=======================================================================
=========
Package Arch Version
Repository Size
=======================================================================
=========
Installing:
net-snmp i386 1:5.3.2.2-17.el5_8.1 updates
703 k
net-snmp-utils i386 1:5.3.2.2-17.el5_8.1 updates
191 k
Installing for dependencies:
lm_sensors i386 2.10.7-9.el5 base 511 k
Transaction Summary
=======================================================================
Install 3 Package(s)
Upgrade 0 Package(s)
Total download size: 1.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): net-snmp-utils-5.3.2.2-17.el5_8.1.i386.rpm | 191 kB
00:00
(2/3): lm_sensors-2.10.7-9.el5.i386.rpm | 511 kB
00:01
(3/3): net-snmp-5.3.2.2-17.el5_8.1.i386.rpm | 703 kB
00:01
——————————————————————————–
Total 408 kB/s | 1.4 MB
00:03
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing :
lm_sensors 1/3
Installing : netsnmp 2/3
Installing : net-snmputils 3/3
Installed: net-snmp.i386 1:5.3.2.2-17.el5_8.1 net-snmp-utils.i386 1:5.3.2.2-17.el5_8.1
Dependency Installed: lm_sensors.i386 0:2.10.7-9.el5
Complete!
  • For RHEL, use command:
    # up2date -v -i net-snmp-utils net-snmp
The SNMP service is now installed.

Configuring the SNMP Service on Linux RHEL/CentOS/Fedora
  1. Edit the file /etc/snmp/snmpd.conf using a text editor such as vi, enter:
    # vi /etc/snmp/snmpd.conf
  2. Press ‘I’ to enter the insert mode. Now, change/modify line(s) as follows:
    Find the following line:

    com2secnotConfigUser default public


    Replace with (make sure you replace 192.168.0.0/24 with your network/subnet) the following lines:


    com2sec local localhost public

    com2secmynetwork 192.168.0.0/24 public

    Scroll down a bit and find the following lines:

    groupnotConfigGroup v1 notConfigUser
    groupnotConfigGroup v2c notConfigUser

    Replace with:

    groupMyRWGroup v1 local
    groupMyRWGroup v2c local
    groupMyRWGroupusm local
    groupMyROGroup v1 mynetwork
    groupMyROGroup v2c mynetwork
    groupMyROGroupusmmynetwork


    Again scroll down a bit and locate the following line:

    viewsystemview included system


    Replace with:

    view all included .1


    Again scroll down a bit and find the following line:

    access notConfigGroup "" any noauth exact systemview none none


    Replace with:

    accessMyROGroup "" any noauth exact all none none
    access MyRWGroup "" any noauth exact all all none


    Scroll down a bit and find the following lines:

    syslocation Unknown (edit /etc/snmp/snmpd.conf)
    syscontact Root (configure /etc/snmp/snmp.local.conf)


    Replace with (make sure you supply appropriate values):

    syslocation Linux (RH3_UP2), Home Linux Router.
    syscontactYourNameHereyou@example.com


    Now to exit the text editor, press “Esc” key and the type “:wq”. This will save the changes you made and then quit the text file.


    Make sure you back up your file by entering the following command:


    # cp /etc/snmp/snmp.conf /etc/snmp/snmp.conf.backup

    • Start your SNMP server and test it:(a) To sure when Linux comes up snmpd always starts after the system reboot
    • # chkconfigsnmpd on
              (b) Start the snmpd service
     # servicesnmpd start

             (c) Finally, test your snmp server
     # snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
The SNMP is now configured.

On Ubuntu

Installing the SNMP Service on:
1. Log in as ROOT user and open the terminal by pressing CTRL+ALT+T.
2. Now enter the following command:
# sudo apt-get update
# sudo apt-get install snmpd
3. This will install SNMP service and show you a completion message.
Configuring the SNMP Service
  1. Type the following command in the terminal to open the text file using text editor ‘vi’:
    # vi /etc/snmp/snmpd.conf
  2. Edit/Update the file as follows:
    rocommunity public
    syslocation “Describe the server’s location”
    syscontact youremail@address.com
  3. Now save and exit the textfile by pressing ENTER and then :wq.
  4. Now edit the following file:
    # vi /etc/default/snmpd
  5. Update it as follows:
# This file controls the activity of snmpd and snmptrapd
# MIB directories. /usr/share/snmp/mibs is the default, but
# including it here avoids some strange problems.
export MIBDIRS=/usr/share/snmp/mibs
# snmpd control (yes means start daemon).
SNMPDRUN=yes
# snmpd options (use syslog, close stdin/out/err).
# replace 204.x.y.z with your public IP
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid
127.0.0.1 204.x.y.z'
# snmptrapd control (yes means start daemon). As of net-snmp
version
# 5.0, master agentx support must be enabled in snmpd before
snmptrapd
# can be run. See snmpd.conf(5) for how to do this.
TRAPDRUN=no
# snmptrapd options (use syslog).
TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
# create symlink on Debian legacy location to official RFC path
SNMPDCOMPAT=yes
  • Restart the SNMP service:
    # /etc/init.d/snmpd restart
The SNMP is now configured.

Starting and Stopping Oracle Service in Linux

Starting Oracle

login as: root on your oracle installed system
To verify service and ports are listening up check with these commands

[root@CENTOS ~]# netstat -ntpul | grep :1521

[root@CENTOS ~]# netstat -ntpul | grep :1522

Then switch to oracle user for starting services

[root@CENTOS ~]# su - oracle

Then start services with these command

[oracle@CENTOS ~]$ lsnrctl start
The command completed successfully

Then run this command

[oracle@CENTOS ~]$ sqlplus

Then run this command

Enter user-name: sys as sysdba
Enter password: mind123
Connected to an idle instance.
SQL> startup
quit command from exit from sql console
SQL> quit
Run this command to start web interface console to manage Oracle database

[oracle@CENTOS ~]$ emctl start dbconsole
Starting Oracle Enterprise Manager 11g Database Control............. started.

Shutdown Oracle Database

To shutdown Oracle server use this command.

[oracle@CENTOS ~]$ sqlplus
Then run this command
Enter user-name: sys as sysdba
Enter password: mind123
Connected to an idle instance.
SQL> shutdown immediate
select TABLE_NAME,TABLESPACE_NAME,STATUS,NUM_ROWS,AVG_ROW_LEN,BLOCKS,EMPTY_BLOCKS from SYS.USER_TABLES WHERE TABLE_NAME LIKE '%RULE_SET*%';