Posts

Showing posts from 2017

how to secure tmp partation in linux

1. Create separte partation for tmp , if you don't have the space to create a fresh /tmp partition on existing drives, you can use the loopback capabilities of the Linux kernel by creating a loopback filesystem that will be mounted as /tmp and can use the same restrictive mount options. To create a 1GB loopback filesystem, execute the following commands. [root@Centos7 ~]# dd if=/dev/zero of=/dev/tmpDIR bs=1024 count=1000000 1000000+0 records in 1000000+0 records out 1024000000 bytes (1.0 GB) copied, 5.32903 seconds, 192 MB/s 2. Backup Current /tmp Directory: Now backup the current /tmp directory using the syntax below which will keep the same permissions for the files currently in /tmp. [root@Centos7 ~]# cp -Rpf /tmp /tmpbak 3.Modify fstab: You should add a line to the end of the /etc/fstab file so the tmp partation so tmp is mounted when the server reboots. /dev/mapper/centos-tmp  /tmp                    xfs     rw,noexec,nosuid,nodev        0 0 /tmp             

NTPd : NTP Server installation on centos7

1. NTP package is provided by default from Centos  repositories, and can be installed by the following command: [root@Centos7 ~]# yum -y install ntp 2. Configure these lines. [root@Centos7 ~]# vi /etc/ntp.conf # line 18: add the network range you allow to receive requests restrict 172.160.0.0 mask 255.255.0.0 nomodify notrap # change servers for synchronization #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server ntp1.example.local iburst server ntp2.example.local iburst 3. Once the installation completes, start the service and configure it so it starts automatically each time the server boots: [root@Centos7 ~]# systemctl start ntpd [root@Centos7 ~]# systemctl enable ntpd 4. Add the NTP service in firewall [root@Centos7 ~]# firewall-cmd --add-service=ntp --permanent success [root@Centos7 ~]# firewall-cmd --reload success 5. To get a basic report you can u

MySql - Convert InnoDB to MyISAM Storage Engine of Database

MySql - Convert InnoDB to MyISAM Storage Engine of Database To convert Database InnoDB Tables to MyISAM steps follow these steps 1. Take the backup of Mysql database [root@Centos7 ]# mysqldump -f --opt mysqldb > /usr/mysqldb.sql 2. Convert the ENGINE from InnoDB to MYISAM  by using below commans. [root@Centos7 ]#mysql -u username -p -e "SELECT concat('ALTER TABLE ', TABLE_NAME,' ENGINE=MYISAM;') FROM Information_schema.TABLES WHERE TABLE_SCHEMA = 'db_name' AND ENGINE = 'InnoDB' AND TABLE_TYPE = 'BASE TABLE'" | tail -n+2 >> /root/MYISAM.sql Note : Update  username and db_name values with your own values. 3. mport that MYISAM.sql file into INNODB database [root@Centos7 ]# mysql -u username -p mysqldb < /root/MYISAM.sql 4. Make it permanent, add to my.cnf default-storage-engine= MyISAM

How to scan new iSCSI disks in Linux ?

How to scan new iSCSI disks in Linux ? 1.First check which are the existing disk available on linux server from fdisk. [root@Centos7 ~]# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier' Disk /dev/xvda: 53.7 GB, 53687091200 bytes, 104857600 sectors Disk /dev/mapper/cl-root: 10.7 GB, 10737418240 bytes, 20971520 sectors Disk /dev/mapper/cl-swap: 5368 MB, 5368709120 bytes, 10485760 sectors Disk /dev/mapper/cl-usr: 10.7 GB, 10737418240 bytes, 20971520 sectors Disk /dev/mapper/cl-home: 2147 MB, 2147483648 bytes, 4194304 sectors Disk /dev/mapper/cl-var: 5444 MB, 5444206592 bytes, 10633216 sectors Disk /dev/mapper/cl-tmp: 2147 MB, 2147483648 bytes, 4194304 sectors 2.Find out how many SCSI controller configured. [root@Centos7 ~]# ls -l /sys/class/scsi_host/ total 0 lrwxrwxrwx 1 root root 0 Dec 11 12:09 host0 -> ../../devices/pci0000:00/0000:00:01.1/ata1/host0/scsi_host/host0 lrwxrwxrwx 1 root root 0 Dec 11 12:09 host1 -> ../../dev

How to install and Configuring manual or automatic node login with iSCSI Initiator

Configuring manual or automatic node login with iSCSI 1. Install the software package: [root@Centos7 ~]# yum -y install iscsi-initiator-utils 2. Configure the iqn name for the initiator: [root@Centos7 ~]# cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.2017-12.com.centos7:Centos7 3. Edit the iSCSI initiator configuration: # vi /etc/iscsi/iscsid.conf # To manually startup the session set to "manual". The default is automatic. node.startup = automatic # To enable CHAP authentication node.session.auth.authmethod = CHAP # To set a CHAP username and password for initiator node.session.auth.username = iscsiadmin node.session.auth.password = P@$$w0rd 4. Start iSCSI initiator daemon: [root@Centos7 ~]# systemctl start iscsi [root@Centos7 ~]# systemctl enable iscsi 5.Discovering targets in our iSCSI server: [root@Centos7 ~]# iscsiadm --mode discovery -t sendtargets --portal 172.16.20.90 172.16.20.90:3260,1 iqn.2004-04.com.sanstorage:tvs-671:iscsi.sa

Enable https on Apache website

How to install OpenSSL and mod ssl First need to install the openssl and mod ssl and then will generating the certificate to be used. Open a terminal prompt and issue the following command  [root@Centos7 conf.d]# yum install mod_ssl Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile  * base: mirror.nbrc.ac.in  * epel: kartolo.sby.datautama.net.id  * extras: mirror.nbrc.ac.in Resolving Dependencies --> Running transaction check ---> Package mod_ssl.x86_64 1:2.4.6-67.el7.centos.5 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================  Package                     Arch                       Version                                     Repository                   Size ======================================================================== Installing:  mod_ssl                     x86_

How install xrdp on CentOS 7 / RHEL 7

How to install xrdp on CentOS 7 / RHEL 7 1. First Install Gnome on CentOS 7 2. Install and configure EPEL repository. [root@Centos7 system]# yum install epel-release Loaded plugins: fastestmirror, langpacks base                                                                                                           | 3.6 kB  00:00:00 extras                                                                                                         | 3.4 kB  00:00:00 updates                                                                                                        | 3.4 kB  00:00:00 updates/7/x86_64/primary_db                                                                                    | 2.7 MB  00:00:07 Loading mirror speeds from cached hostfile  * base: ftp.iitm.ac.in  * extras: ftp.iitm.ac.in  * updates: ftp.iitm.ac.in Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-9 will be installed --> Finished D

How to fix postfix/smtp Network is unreachable error

While configuration postfix authentication getting the error status=deferred (delivery temporarily suspended: connect to smtp.office365.com[2603:1026:3:ca::2]:587: Network is unreachable) its because of you were not using IPv6/ wrong settings for ipv6. You can either use IPv4, or correct your IPv6 settings. [root@mailserver postfix]# netstat -nutlap | grep 25 tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      3956/master tcp        0      0 127.0.0.1:38442         127.0.0.1:3306          ESTABLISHED 2596/httpd [root@mailserver postfix]# vi /etc/postfix/main.cf [root@mailserver postfix]# systemctl restart postfix [root@mailserver postfix]# netstat -nutlap | grep 25 tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      4079/master tcp        0      0 127.0.0.1:38442         127.0.0.1:3306          ESTABLISHED 2596/httpd tcp6       0      0 :::25                   :::*                    LISTEN      407

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

Getting the error while running the sudo -s to become root sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set 1.Login the server using root and change the permission of /usr/bin/sudo chmod 4755 /usr/bin/sudo 2. if you do not have root password then reboot the server on single usermode and run these commands. mount -o remount,rw /dev/mapper/lv_root / chown root:root /usr/bin/sudo chmod 4755 /usr/bin/sudo restart

issuse :SASL(-1): generic failure: GSSAPI Error: Unspecified GSS failure. Minor code may provide more information (Server not found in Kerberos database)

root@HPUX:~# realm join --user=domainuser  windows.local  --install=/ -v  * Resolving: _ldap._tcp.windows.local  * Resolving: windows.local  * Performing LDAP DSE lookup on: 192.16.100.194  * Successfully discovered: windows.local Password for domainuser:  * Assuming packages are installed  * LANG=C /usr/sbin/adcli join --verbose --domain windows.local --domain-realm WINDOWS.LOCAL --domain-controller 192.16.100.194 --login-type user --login-user domainuser --stdin-password  * Using domain name: windows.local  * Calculated computer account name from fqdn: HPUX  * Using domain realm: windows.local  * Sending netlogon pings to domain controller: cldap://192.16.100.194  * Received NetLogon info from: GDCADC001.windows.local  * Wrote out krb5.conf snippet to /var/cache/realmd/adcli-krb5-OYG8o8/krb5.d/adcli-krb5-conf-QbSlJr  * Authenticated as user: domainuser@WINDOWS.LOCAL  ! Couldn't authenticate to active directory: SASL(-1): generic failure: GSSAPI Error: Unspecified

Could not join realm: Necessary packages are not installed: sssd-tools sssd libnss-sss libpam-sss adcli

Couldn't join realm: Necessary packages are not installed: sssd-tools sssd libnss-sss libpam-sss adcli root@HPUX:~# realm join --user=domainuser@windows.local  windows.local -v  * Resolving: _ldap._tcp.windows.local  * Resolving: windows.local  * Performing LDAP DSE lookup on: 192.168.20.24  * Successfully discovered: windows.local Password for domainuser@windows.local:  * Unconditionally checking packages  * Resolving required packages  ! Necessary packages are not installed: sssd-tools sssd libnss-sss libpam-sss adcli realm: Couldn't join realm: Necessary packages are not installed: root@HPUX:~# apt-get install sssd-tools sssd libnss-sss libpam-sss adcli Reading package lists... Done Building dependency tree Reading state information... Done adcli is already the newest version (0.8.1-1). libnss-sss is already the newest version (1.13.4-1ubuntu1.7). libpam-sss is already the newest version (1.13.4-1ubuntu1.7). sssd is already the newest version (1.13.4-1u

EPEL Repository in RHEL/CentOS 7/6

 EPEL Repository in RHEL/CentOS 7/6 To enable the EPEL repository on CentOS 7.x, RedHat 7.x, or Oracle Linux 7.0/7.1 This section describes how to download and install the EPEL repository. Download the EPEL repository: wget http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm Install the EPEL repository: rpm -Uvh epel-release-7*.rpm Or you can use the commands [root@Centos7 ~]# yum install epel-release Loaded plugins: fastestmirror, langpacks epel/x86_64/metalink                    

install nrpe plugins on Ubuntu & Centos

install nrpe plugins  on Ubuntu & Centos  Find the source code for the latest stable release of NRPE at the NRPE downloads page. Download the latest version to your Nagios server. root@nagiosclient:/# cd /tmp root@nagiosclient:/tmp# wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.0/nrpe-3.2.0.tar.gz --2017-09-11 14:34:41--  https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.0/nrpe-3.2.0.tar.gz Resolving github.com (github.com)... 192.30.255.112, 192.30.255.113 Connecting to github.com (github.com)|192.30.255.112|:443... connected. HTTP request sent, awaiting response... 302 Found Location:  Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|54.231.120.35|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 517743 (506K) [application/octet-stream] Saving to: ‘nrpe-3.2.0.tar.gz’ nrpe-3.2.0.tar.gz