Kali Linux Mirrors

I had issues after installing Kali Linux with apt not working, ended up there were no repositories in the apt sources list, added the following line and did an apt-get update and everything started working.

Add this line to /etc/apt/sources.list

deb http://http.kali.org/kali kali-rolling main non-free contrib

Update

apt-get update

And dist upgrade

apt-get dist-upgrade

You may need to reboot.

reboot

Cannot open mailbox /var/mail/pi: Permission denied

This is on a Raspberry Pi, but should be the same on any Linux distro.

Error :

pi@raspberrypi:~ $ mail
Cannot open mailbox /var/mail/pi: Permission denied
No mail for pi
pi@raspberrypi:~ $ 

Fix :

sudo touch /var/mail/$USER
sudo chown $USER:mail /var/mail/$USER
sudo chmod 660 /var/mail/$USER

You can replace “$USER” if you need to run the commands for a different account.
Example:

sudo touch /var/mail/pi
sudo chown pi:mail /var/mail/pi
sudo chmod 660 /var/mail/pi

How To export private SSH key on Linux

All that needs to be done is the “id_rsa” key needs to be copied to the “new” host.  You can do this with SCP or sftp.

Example with SCP

The following examples are showing how to export a RSA private key, if your using DSA, then replace id_rsa with id_dsa.

Copy private key from remote server to local machine for the local user

scp root@192.168.1.1:~/.ssh/id_rsa ~/.ssh/

Copy private key from localhost to remote host.  This command copies the local users private key to the root user @ 192.168.1.1

scp ~/.ssh/id_rsa root@192.168.1.1:~/.ssh/

 

Mikrotik Backup Script

This is a Linux script for creating and backing up backups on Mikroitk routers.

Features

  • Creates the backups automatically, no need to manually create a backup on the Mikrotik
  • Uses SSH and SCP for encrypted communication between the router and the server
  • Runs on linux
  • Easy to use command line interface
  • Can back up single or multiple routers

Future Features

These are features I am planning on adding to the script in the future

  • Ability to compare backups and remove duplicates
  • Make the script smarter so it can detect a backup on a router and leave it instead of deleting it
  • Add better logging
  • Add the functionality to upload the backups to an online service like DropBox, or OneDrive automatically
  • Add alert mechanism to alert you if a backup failed or router is unreachable

Current Bugs or limitations

  • Deletes all backups off of the router, so if you manually created a backup it will delete it without asking
  • To stop backing up a router, you’ll need to manually delete the IP address out of the IP database i.e(ip.lst file.)
  • It does not currently have the ability to delete backups

 

Requirements

  1. Linux box to run the script from and to store the backups.  You can run it from a laptop or VirtualBox.
  2. You’ll need the following programs for this script to work(fping, sshpass)
  3. The Linux box need to be able to ping the routers, if it can’t the script will fail

Installing

Download program

wget www.incredigeek.com/home/downloads/mtbackup/mtbackup.sh
chmod +x mtbackup.sh

Now open up the script and edit the variables at the top for your username, password, and where you want the backups.

 nano mtbackup.sh

When you have finished editing the variables, hit CTRL+x, and then “y” and then “enter” to save the file.

If you want to setup the script to backup on a regular basis then setup the script to run in cron.

Run “crontab -e” and add the following line

10 1 * * 1 cd /root/mtbackup-1.0/ & sh mtbackup -b

Hit CTRL+x, and then “y” and then “enter” to save the file.

Adding routers to backup

Adding routers is really easy.  All you have to do is run the script with the -a option and then the ip address and the script will check if it can reach the IP and then add it to the IP Database i.e.(ip.lst file that contains all the routers ip addresses)
./mtbackup.sh -a 192.168.88.1

Example:

[root@localhost mtbackup-1.0]# ./mtbackup.sh -a 192.168.88.1
#################################################################

This is a Mikrotik Backup Utility.  Still being updated and worked on!!!

#################################################################

Adding 192.168.88.1 to the ip DB
Added 192.168.88.1 to ipDB
[root@localhost mtbackup-1.0]#

Backing up all routers

You can manually backup all the routers by running the script with just the “-b” option.  It’ll read every IP in the IP database and create a backup for each one and put it in the backup folder with is normally “./backups”, you can change it in the variables portion of the script.

./mtbackup.sh -b

Other examples

List routers in the IP Database

 [root@localhost mtbackup-1.0]# ./mtbackup.sh -L
#################################################################
This is a Mikrotik Backup Utility. Still being updated and worked on!!!
#################################################################
Listing Hosts...
192.168.88.1
10.200.1.1
172.20.1.1
33.11.2.22
[root@localhost mtbackup-1.0]#

Backup Single router

[root@localhost mtbackup-1.0]# ./mtbackup.sh -B 192.168.88.1
#################################################################

This is the Mikrotik Backup Utility. Currently under construction!!!

#################################################################

Starting to do backup on 10.9.0.1

Configuration backup saved
[root@localhost mtbackup-1.0]#

Other commands

[root@localhost mtbackup-1.0]# ./mtbackup.sh -h
#################################################################

This is the Mikrotik Backup Utility.  Still being updated and worked on!!!

#################################################################

Usage
./mtbackup.sh [OPTIONS]
./mtbackup.sh -b 192.168.88.1

-l      List backups
-L      List Hosts
-b      Backup all hosts in the IP database
-B {ip} Backup Single Host, Specife IP
-a {ip} Add ip to IP database
-v      Version

[root@localhost mtbackup-1.0]#

Not able to remove ZenPack – Zenoss 5

Ran into an issue where I was not able to list the installed ZenPacks and Zenoss was having issues starting. I think it was due to a ZenPack having issues and not being installed properly.

Drop into the container

serviced service shell -i -s FixZenpack zope bash

Change user and cd to ZenPack directory

su zenoss
cd /opt/zenoss/ZenPacks

Once there, remove the offending ZenPack. Replace ZENPACK.egg with the ZenPack

rm -rf ./ZENPACK.egg

Example:

rm -rf ./ZenPacks.zenoss.MikroTik-1.1.1.egg

Exit out of the container.

exit
exit

You can also hit ctrl+d twice.
Commit the Container

 serviced service shell -i -s FixZen zope bash

Restart the Zenoss.Core Service

service service restart Zenoss.Core

How To remove a ZenPack from Zenoss 5

To remove a ZenPack on Zenoss 5.1 and later, you are going to need to stop the zenoss services, restart a couple services that are needed to install the ZenPack, install the ZenPack, and then restart the Zenoss service.

Stop Zenoss.Core

serviced service stop Zenoss.Core

Make sure the service is stopped by running the following command.  When it reports back the Zenoss is Stopped, then continue.

 if ( serviced service status Zenoss.Core | awk '{print $3}' | grep -q Stopped) ; then echo "Zenoss is not running!" ; else echo "Zenoss is not Stopped!" ; fi

Or you can run this command, just make sure it says it is stopped.

serviced service status zenoss.core

Create a Snapshot

serviced service snapshot Zenoss.core

Start the following three services

serviced service start Infrastructure
zeneventserver
Zope

serviced service start Infrastructure
serviced service start zeneventserver
serviced service start Zope

List the ZenPacks that are currently installed.

serviced service run zope zenpack list

Remove the ZenPack.  Replace “ZenPack.comunity.Zenpack” with the zenpack name from the previous command.

serviced service run zope zenpack-manager uninstall ZenPack.community.Zenpack

How To use the Zenoss Toolbox

This is all contained in the Zenoss Upgrade guide.

Attach to Zope

serviced service attach zope/0
su zenoss

You can run the following commands to check on zenoss

zenossdbpack
findposkeyerror
zenrelationscan
zencatalogscan

zenossdbpack : Quickly scans the Zope Object Database (ZODB) to provide a preliminary indication of the health of the database, and to determine whether the database needs to be compressed with “zenossdbpack” before upgrading.
findposkeyerror : Checks objects and their relationships, and provides options for fixing errors.
zenrelationscan : Checks only ZenRelations between objects.
zencatalogscan : Checks ZODB object catalogs, which speed up web interface access

How To Install the Zenoss Tool Box

Skip to the bottom if you just want to see all of the commands.

Make a temporary directory

mkdir /tmp/toolbox
cd /tmp/toolbox

Download the tool box

wget https://github.com/zenoss/zenoss.toolbox/archive/master.zip
chmod -R 777 /tmp/toolbox

Drop to a shell and switch user

serviced service shell -i -s ToolBox zope bash
su zenoss

Install

easy_install /mnt/pwd/master.zip

Exit and commit container

exit
exit
serviced snapshot commit ToolBox

Restart Zope

serviced service restart zope

 

All the commands:

mkdir /tmp/toolbox && cd /tmp/toolbox
wget https://github.com/zenoss/zenoss.toolbox/archive/master.zip
chmod -R 777 /tmp/toolbox
serviced service shell -i -s ToolBox zope bash
su zenoss
easy_install /mnt/pwd/master.zip
exit
exit
serviced snapshot commit ToolBox
serviced service restart zope