Allow SSH access from a specific host using hosts.allow and hosts.deny on Linux

This is just a quick write on the hosts.allow and deny files.  You can lookup “spawn” and/or “twist” for some advanced usage.

 

So to limit an IP address, or a IP range access to SSH, do the following

Deny all incoming request for SSH

Edit the “hosts.deny” file

vi /etc/hosts.deny

add the following line

sshd : ALL

Now edit “hosts.allow” and allow the client IP, or IP range to access SSH

vi /etc/hosts.allow

add the following line to allow a single IP

sshd : 192.168.1.182

If you want to allow the whole subnet, then replace the above line with this one

sshd : 192.168.1.

hosts.allow overrides hosts.deny.  So you deny everything and then allow exceptions.

Setting up MySQL for FreeRadius

Install Mysql

yum install mariadb mariadb-client mariadb-server freeradius-mysql

Setup MySQL database.

mysql -u root -p
CREATE DATABASE radius;
GRANT ALL ON radius.* TO radius@localhost IDENTIFIED BY "RadiusPassword";
exit

Import the schema.sql file into the db.

mysql -u radius -p radius < /etc/raddb/mods-config/sql/main/mysql/schema.sql

Should be good to go.

Install VirtualBox Guest Additions for Fedora 22

Install kernel headers, dkms, etc

dnf -y kernel-headers kernel-devel dkms gcc gcc-c++

Reboot the VM

reboot

Mount the Guest Additions by going to menu > Devices > Insert Guest Additions CD image… or you can hit “Host + D”.

The Host key is typically the Right Ctrl(On Windows) or CMD(On OS X) key.

 

Installing the Guest Additions

Via the GUI

Mount the Guest Additions from your file browser, and then launch the “VBoxLinuxAdditions.run”.

You will need root privileges, so either launch your file browser as root, or drag and drop the “VBoxLinuxAdditions.run”, into a root terminal and hit Enter.

Via Command Line

mkdir /tmp/vbox
sudo mount /dev/cdrom /tmp/vbox
sudo /tmp/vbox/VBoxLinuxAdditions.run

If you run into any errors, try ejecting, and remounting the Guest Additions cd.

Install Wireless Broadcom Driver for Fedora 21

Run the following commands as root

rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

Update the system and then download the driver.

yum update
yum install kmod-wl

When the above commands finish reboot the computer

reboot

How to View Installed Programs in linux

Debian Based Distros

The below command should work for Debain, Ubuntu, and the Raspberry Pi Raspbian.

dpkg --get-selections

 

RPM Based Distros

The following works on Fedora, CentOS, ReHat.

rpm -qa

 

The above commands return all of the packages installed on a system.  If you want to look for a specific program or package you can use grep to filter the results.

rpm -qa | grep program

or

dpkg --get-selections | grep program

How to set a static ip address on CentOS, Fedora, or Red Hat Linux

Open up the following file with your favorite text editor. Change eth0 to the interface you need, like “wlan0” or “eth1”.

 vi /etc/sysconfig/network-scripts/ifcfg-eth0

The file should look something like the following.

DEVICE=eth0
HWADDR=0A:2G:F3:56:66:4B
TYPE=Ethernet
UUID=aeh9421c-6a62-712c-886d-347813g8d1dh
ONBOOT=no
NM_CONTROLLED=yes
BOOTPROTO=dhcp

To set the static IP address change “BOOTPROTO=dhcp” to “BOOTPROTO=static” and add the following to the end of the file. If you want/need the interface to come up when the computer boots up then be sure to change “ONBOOT=no” to “ONBOOT=yes”.

BROADCAST=192.168.1.255
DNS1=8.8.8.8
GATEWAY=192.168.1.1
IPADDR=192.168.1.110
NETMASK=255.255.255.0

Also, on some newer versions of CentOS you may need to add NM_DISABLED=no

So your file should now look like this.

DEVICE=eth0
HWADDR=0A:2G:F3:56:66:4B
TYPE=Ethernet
UUID=aeh9421c-6a62-712c-886d-347813g8d1dh
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
BROADCAST=192.168.1.255
DNS1=8.8.8.8
GATEWAY=192.168.1.1
IPADDR=192.168.1.110
NETMASK=255.255.255.0

Save the file and restart networking.

service network restart

Finally, check you IP address with ifconfig.

root@localhost ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 0A:2G:F3:56:66:4B  
          inet addr:192.168.1.110  Bcast:192.168.1.255  Mask:255.255.255.0

How To Make a Live Bootable Fedora Thumb Drive in Linux

Insert your thumb drive into the computer.

We need to find out where the thumb drive is mounted.  We can do this with the “df” command as shown below or you can find it in dmesg.

So if we run the df command

df -h

It returns something like this

[me@fedora ~]$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-root   50G   11G   37G  23% /
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G  1.2M  1.9G   1% /dev/shm
tmpfs                    1.9G  1.1M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs                    1.9G   52K  1.9G   1% /tmp
/dev/sdb1                477M  115M  333M  26% /boot
/dev/mapper/fedora-home  176G  125G   42G  75% /home
/dev/sdc1                3.8G  3.2G  592M  85% /run/media/me/136A-7360
[me@fedora ~]$

Note that the bottom one is the thumb drive /dev/sdc1 yours may differ.

Now that we know where the drive is mounted we can write the image to the thumb drive.

Change the path in “if=/” to the path to your Fedora iso and change “of=/” to you thumb drive path

su -c "dd if=/home/me/Downloads/Fedora-Live-x86_64-20-1.iso of=/dev/sdc bs=8M"

It will take a couple of minutes to complete and it will not give you any information until it is finished.

Congratulations, you now have a live working Fedora thumb drive.

How to Install Flash on Linux

Installing flash on Ubuntu is pretty straight forward.  Type the following command into a terminal and press enter and away you go.

sudo apt-get install flashplugin-installer

On Fedora need to do the following

(64-bit)

sudo yum install http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm -y

(32-bit)

sudo yum install http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm -y

And install the Adobe Flash web browser plugin.  The first command imports the GPG key for the Adobe Flash plugin repository and the second command installs the plugin itself.

sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux 
sudo yum install flash-plugin -y