Sunday, September 1, 2019

Use nmap to get list of active IP addresses on the network

[malex@thermalite ~]$ nmap -sP 192.168.1.1/24

Starting Nmap 7.60 ( https://nmap.org ) at 2019-08-03 12:03 EDT
Nmap scan report for Fios_Quantum_Gateway.fios-router.home (192.168.1.1)
Host is up (0.00059s latency).
Nmap scan report for 192.168.1.100
Host is up (0.00011s latency).
Nmap scan report for 192.168.1.114
Host is up (0.0011s latency).
Nmap scan report for localhost.fios-router.home (192.168.1.151)
Host is up (0.0010s latency).
Nmap scan report for iPhone7-Cheche.fios-router.home (192.168.1.155)
Host is up (0.012s latency).
Nmap scan report for 192.168.1.157
Host is up (0.023s latency).
Nmap scan report for 192.168.1.223
Host is up (0.0061s latency).
Nmap scan report for raspberrypi312.fios-router.home (192.168.1.229)
Host is up (0.0042s latency).
Nmap scan report for raspberrypi313.fios-router.home (192.168.1.233)
Host is up (0.0054s latency).
Nmap scan report for raspberrypi313.fios-router.home (192.168.1.234)
Host is up (0.0053s latency).
Nmap scan report for raspberrypi1.fios-router.home (192.168.1.235)
Host is up (0.0052s latency).
Nmap scan report for RE6500-391.fios-router.home (192.168.1.248)
Host is up (0.0010s latency).
Nmap scan report for raspberrypi.fios-router.home (192.168.1.249)
Host is up (0.11s latency).
Nmap scan report for raspberrypi1.fios-router.home (192.168.1.250)
Host is up (0.0015s latency).
Nmap scan report for raspberrypi312.fios-router.home (192.168.1.254)
Host is up (0.015s latency).
Nmap done: 256 IP addresses (15 hosts up) scanned in 3.85 seconds
[malex@thermalite ~]$

Installing Jenkins on Fedora 28

1. Remove Java and Jenkins
   [root@thermalite ~]# yum remove jenkins
   [root@thermalite ~]# yum remove java

2. Install Jenkins, Java and Git
   [root@thermalite ~]# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
   [root@thermalite ~]# rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
   [root@thermalite ~]# yum install jenkins java git -y

3. Start Jenkins service
   [root@thermalite ~]# systemctl start jenkins.service
   [root@thermalite ~]# systemctl stop jenkins.service
   [root@thermalite ~]# systemctl start jenkins.service
   [root@thermalite ~]# systemctl status jenkins.service

4. Check firewall
[root@thermalite ~]# firewall-cmd --get-active-zones
home
  interfaces: enp2s0

[root@thermalite ~]# firewall-cmd --list-all
home (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp2s0
  sources:
  services: ssh mdns samba-client dhcpv6-client http jenkins
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

[root@thermalite ~]#

5. Open browser url: http://192.168.1.100:8080

6. Edit /etc/sysconfig/jenkins to change port from 8080 to 9191
     JENKINS_PORT="9191"

7. Restart Jenkins
[root@thermalite ~]# systemctl stop jenkins
[root@thermalite ~]# systemctl start jenkins
[root@thermalite ~]# systemctl status jenkins


sudo usermod -s /bin/bash jenkins
sudo usermod -m /var/lib/jenkins jenkins
sudo su - jenkins
curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled

Installing a Raspbian

1. Download image from URL: https://downloads.raspberrypi.org/raspbian_lite_latest

2. Using win32 Disk Image program, write the 2019-06-20-raspbian-buster-full.img to the mini-sd card.

3. Raspbian stretch Lite default login Linux users. User management in Raspbian is done on the command line.

The default
user is pi , and the
password is raspberry .

You can add users and change each user's password.

4. install ssh
 $ sudo apt-get install openssh-server openssh-client

5. Alternatively, use systemctl to start the service
 $ sudo systemctl enable ssh
 $ sudo systemctl start sshapt-get

6. Add user malex
 $ sudo adduser malex

7. Add malex as sudoers
 $ sudo vi /etc/sudoers

 add:
 malex   ALL=(ALL:ALL) ALL

8. passwordless ssh
 $ sudo ls -al ~/.ssh/id_*.pub
 $ sudo ssh-keygen -t rsa -b 4096 -C "azmadriaga@gmail.com"
 $ sudo ssh-copy-id malex@192.168.1.100

9. sudo apt-get install nmap

10. sudo apt-get install xrdp

TBD



TBD


Thursday, October 20, 2016

Install Oracle JDK 8 and Apache Tomcat 8

Installing the Oracle JDK
=========================

1. sudo add-apt-repository ppa:webupd8team/java
2. sudo apt-get update
3. sudo apt-get install oracle-java8-installer
4. sudo update-alternatives --config java
5. sudo vi /etc/environment
 JAVA_HOME="/usr/lib/jvm/java-8-oracle"
6. source /etc/environment


Installing Apache Tomcat 8
==========================
1. sudo apt-get install tomcat8 tomcat8-docs tomcat8-admin tomcat8-examples
2. dpkg -L tomcat8
3. sudo vi /etc/tomcat8/server.xml

change port 8080 to 8081 since jenkins is using 8080

4. sudo /etc/init.d/tomcat8 restart
5. Check: http://localhost:8081
6. sudo vi /opt/tomcat/conf/tomcat-users.xml
7. sudo /etc/init.d/tomcat8 restart

Re-installing Tomcat 8
======================
1. Getting errors

 Errors were encountered while processing:
 tomcat8
 E: Sub-process /usr/bin/dpkg returned an error code (1)

2. sudo dpkg -P libtomcat8-java tomcat8-common tomcat8-docs tomcat8 tomcat8-examples tomcat8-admin

3. sudo apt-get purge libtomcat8-java tomcat8 tomcat8-admin tomcat8-common tomcat8-docs tomcat8-examples tomcat8-user

4. sudo reboot

Install Oracle JDK 8 and Apache Tomcat 8

Installing the Oracle JDK
=========================

1. sudo add-apt-repository ppa:webupd8team/java
2. sudo apt-get update
3. sudo apt-get install oracle-java8-installer
4. sudo update-alternatives --config java
5. sudo vi /etc/environment
   JAVA_HOME="/usr/lib/jvm/java-8-oracle"
6. source /etc/environment


Installing Apache Tomcat 8
==========================
1. sudo apt-get install tomcat8 tomcat8-docs tomcat8-admin tomcat8-examples
2. dpkg -L tomcat8
3. sudo vi /etc/tomcat8/server.xml
change port 8080 to 8081 since jenkins is using 8080

4. sudo /etc/init.d/tomcat8 restart
5. Check: http://localhost:8081
6. sudo vi /opt/tomcat/conf/tomcat-users.xml 
7. sudo /etc/init.d/tomcat8 restart



Re-installing Tomcat 8
======================
1. Getting errors

   Errors were encountered while processing:
   tomcat8
   E: Sub-process /usr/bin/dpkg returned an error code (1)

2. sudo dpkg -P libtomcat8-java tomcat8-common tomcat8-docs tomcat8 tomcat8-examples tomcat8-admin

3. sudo apt-get purge libtomcat8-java tomcat8 tomcat8-admin tomcat8-common tomcat8-docs tomcat8-examples tomcat8-user

4. sudo reboot








Install Oracle JDK 8 and Apache Tomcat 8

Installing the Oracle JDK
=========================

1. sudo add-apt-repository ppa:webupd8team/java
2. sudo apt-get update
3. sudo apt-get install oracle-java8-installer
4. sudo update-alternatives --config java
5. sudo vi /etc/environment
   JAVA_HOME="/usr/lib/jvm/java-8-oracle"
6. source /etc/environment


Installing Apache Tomcat 8
==========================
1. sudo apt-get install tomcat8 tomcat8-docs tomcat8-admin tomcat8-examples
2. dpkg -L tomcat8
3. sudo vi /etc/tomcat8/server.xml
change port 8080 to 8081 since jenkins is using 8080

4. sudo /etc/init.d/tomcat8 restart
5. Check: http://localhost:8081
6. sudo vi /opt/tomcat/conf/tomcat-users.xml 
7. sudo /etc/init.d/tomcat8 restart



Re-installing Tomcat 8
======================
1. Getting errors

   Errors were encountered while processing:
   tomcat8
   E: Sub-process /usr/bin/dpkg returned an error code (1)

2. sudo dpkg -P libtomcat8-java tomcat8-common tomcat8-docs tomcat8 tomcat8-examples tomcat8-admin

3. sudo apt-get purge libtomcat8-java tomcat8 tomcat8-admin tomcat8-common tomcat8-docs tomcat8-examples tomcat8-user

4. sudo reboot









Installing monit in Ubuntu (IP: 10.20.30.40)


1. Repair missing LSB tags on tomcat and vncserver and other daemon as well

   $ sudo vi tomcat 
   $ sudo vi vncserver 
  
  add this after shebang
  
  ### BEGIN INIT INFO
  # Provides:          skeleton
  # Required-Start:    $remote_fs $syslog
  # Required-Stop:     $remote_fs $syslog
  # Default-Start:     2 3 4 5
  # Default-Stop:      0 1 6
  # Short-Description: Example initscript
  # Description:       This file should be used to construct script
  #                    placed in /etc/init.d.
  ### END INIT INFO
  
  
2. Install monit
   $ sudo apt-get install monit
   
   
3. Edit /etc/monit/monitrc
$ sudo vi /etc/monit/monitrc

3.1. Uncomment this section:

set httpd port 2812 and
         use address 10.20.30.40 # only accept connection from localhost
         allow 0.0.0.0/0.0.0.0   # allow localhost to connect to the server and
         allow admin:monit      # require user 'admin' with password 'monit'
         allow @users readonly  # allow users of group 'users' to connect readonly 

3.2. Append at the end of the config

# monitor sshd
check process sshd with pidfile /var/run/sshd.pid
#
# monitor jenkins
check process jenkins with pidfile /var/run/jenkins/jenkins.pid
#
# monitor apache2
check process apache2 with pidfile /var/run/apache2/apache2.pid


4. Install upstart
$ sudo apt-get install upstart-sysv

5. Reload monit
$ sudo reload monit

OR

$ sudo service monit restart

6. Open browser and check
http://10.20.30.40:2812/

Thursday, January 29, 2015

Adding a non-root users to access SSH in WD My Book Live

Regular (non-root) user's SSH password

URL: http://community.wd.com/t5/My-Book-Live/what-s-my-normal-non-root-user-s-SSH-password/td-p/566360 

Not Not simple, but not too complicated as well. Be careful. Something wrong and you might get locked out.

If I remember all my steps, this is what I did. Make sure you save backups copies for the files before you edit them.

- Enable ssh:
http:///UI/ssh

- Create shares, users, set passwords and permissions via dashboard

- Allow Users to SSH:
edit file /etc/ssh/sshd_config
Change "AllowUsers" line by adding user names such as:
AllowUsers root user1 user2

- Optional: Set users home dir: edit file /etc/passwd
The following will set home dir to "Public"
Change from "/shares:/bin/sh" to "/shares/Public:/bin/sh"

- Restart ssh deamon or reboot:
/etc/init.d/ssh restart

Test ssh for your users within the home network. If all works, then proceed to:
- Set your router to forward port TCP 22
- Set DDNS on your router

===========
Using Cygwin
malex@laptop /home/malex/manuals
$ pwd
/home/malex/manuals

malex@laptop /home/malex/manuals

$ ./rsyncEbookPush.sh

#!/bin/bash

rUser="malex@192.168.10.250"

rsync --remove-source-files -avzhe "ssh -q"  --exclude "rsyncEbook*.sh"  --progress /home/malex/manuals/ "$rUser":/shares/Public/Manuals


$ ./rsyncEbookPull.sh

#!/bin/bash

rUser="malex@192.168.10.250"

rsync -avzhe "ssh -q"  --exclude "rsyncEbook*.sh"   --progress "$rUser":/shares/Public/Manuals/  /home/malex/manuals





Saturday, January 11, 2014

How to calculate 95th percentile of values with grouping variable in Excel

Sample data:
     A            B           C          D
1 Watershed   WQ
2 50500101    62.370661    50500101     {formula here}
3 50500101    65.505046
4 50500101    58.741477
5 50500105    71.220034
6 50500105    57.917249
 
Excel formula in D2 :
 
{=PERCENTILE(IF($A2:$A6=C2, $B$2:$B$6), 0.95)} 

Also, be sure to enter the formula as an array formula. 
Do so by pressing Ctrl+Shift+Enter when entering the formula. 
 
http://stackoverflow.com/questions/5473537/how-to-calculate-95th-percentile-of-values-with-grouping-variable-in-r-or-excel