Showing posts with label RPI. Show all posts
Showing posts with label RPI. Show all posts

Friday, October 2, 2015

Authentication Management

How To Monitor System Authentication Logs on Ubuntu


How To Monitor System Logins
A fundamental component of authentication management is monitoring the system after you have configured your users.

Luckily, modern Linux systems log all authentication attempts in a discrete file. This is located at "/var/log/auth.log":
sudo less /var/log/auth.log
How To Use the "last" Command
Usually, you will only be interested in the most recent login attempts. You can see these with the "last" tool:
This gives a formated version of the "/etc/log/wtmp" file.
last
As you can see, in the first and third line, it shows that the user is still logged into the system. Otherwise, the total time logged into the system during a session is given by a set of hyphen-separated values.


How To Use the "lastlog" Command
If you would like to look at this situation from a different angle, you can view the last time each user on the system logged in.

This information is provided by accessing the "/etc/log/lastlog" file. It is then sorted according to the entries in the "/etc/passwd" file:
lastlog
You can see the latest login time of every user on the system.

Notice how the system users will almost all have "**Never logged in**". We saw earlier how these accounts do not have password authentication set up, so this is the expected value.


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


Change the default SSH port

In this How-To we're going to walk you though changing the default SSH port on a Linux system.

The Secure Shell (SSH) Protocol by default uses port 22. Accepting this value does not make your system insecure, nor will changing the port provide a significant variance in security. However, changing the default SSH port will stop many automated attacks and a bit harder to guess which port SSH is accessible from. In other words, a little security though obscurity.


Before getting started, we suggest you Learn Linux Basics and follow these precautions.
Steps to follow
Step 1
As root, use your favorite text editor (nano) to edit the sshd configuration file.

nano /etc/ssh/sshd_config

Step 2
Edit the line which states 'Port 22'. But before doing so, you'll want to read the note below. Choose an appropriate port, also making sure it not currently used on the system.

# What ports, IPs and protocols we listen for
Port 50683

Note: The Internet Assigned Numbers Authority (IANA) is responsible for the global coordination of the DNS Root, IP addressing, and other Internet protocol resources. It is good practice to follow their port assignment guidelines. Having said that, port numbers are divided into three ranges: Well Known Ports, Registered Ports, and Dynamic and/or Private Ports. The Well Known Ports are those from 0 through 1023 and SHOULD NOT be used. Registered Ports are those from 1024 through 49151 should also be avoided too. Dynamic and/or Private Ports are those from 49152 through 65535 and can be used. Though nothing is stopping you from using reserved port numbers, our suggestion may help avoid technical issues with port allocation in the future.

Step 3
Switch over to the new port by restarting SSH.

/etc/init.d/ssh restart

Step 4
Verify SSH is listening on the new port by connecting to it. Note how the port number now needs to be declared.

ssh username@hostname.com -p 50683



-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


Friday, August 28, 2015

connecting to RPi threw the internet (router sitting)

first of all turn of the firewall of the router and also the SPI

Second join and connect the ports that you want (SSH , HTTP , VNC , ....) between the global network and the internal IP of the RPi

----------------
i tested the connection from my mobile using the Data (4G network) 
i tested (SSH , HTTP , VNC ) and succeeded 

Friday, July 3, 2015

List of usefull command line (updated)

* Last reboot time
      last reboot;

* Searching command
      greb filename;

* Searching for file in the computer
      tree -fa | grep filename;

* Real internet ip
     curl ifconfig.me;
     curl icanhazip.com;

* Real-time view of a running system.
     top
http://www.tecmint.com/12-top-command-examples-in-linux/

* vcgencmd
     vcgencmd measure_temp     vcgencmd measure_clock arm
     vcgencmd measure_volts core
http://elinux.org/RPI_vcgencmd_usage
http://www.maketecheasier.com/finding-raspberry-pi-system-information/


*Change mode of file
     chmod u=rwx,g=rx,o=r myfile

*testing PHP file
    php -f filename.php


*php information function

   <?php phpinfo();

*The sudo command can be used to obtain the privileges of other users too. I've installed the Apache web server, and the user www-data is automatically created during this process. If I want to edit a file using www-data's permissions, I can use the -u option:
  
   sudo -u www-data nano /var/www/somefile.txt


Powering Rpi with power bank (updated)


Now i had buy new power bank (InnJoo E1 10000mAh Powerbank) with specs ( Capacity: 10000mAh - Input: 5V/1A - Output: 5V/2A );

when i full charged it , it can power on the Rpi connected to wifi dongle

but i want to test how much time it will survive it

so i used this code to save the run time and save time every 30 sec

    while :; do date >> time_servive_test.txt; sleep 30; done

when i open the file "time_servive_test.txt" it will have a saving if time every 30 sec 
so to know  if it works will you can use this command line to count the numbers of test executed 


    wc -l time_servive_test.txt


i will publish the result of my test :) soon (inshaa Allah)
------------

i had updated the code to be interval every 1 minuet 
also i had added a chick  for global ip address

   echo 'start saving time';
   echo '' > time_servive_test.txt;
   while :;
   do
        date >> time_servive_test.txt;
        curl icanhazip.com; >> time_servive_test.txt;
        sleep 60;
   done

-------------------------------------------------------------------------
finally the test had been finished 
the power-bank of 10000 mAh survived the  Raspberry pi for more than 11 hours (around 12 or more).

when i used the command sudo shutdown -h now the raspy shutdown and the power disconnected , when i pressed the power of the power-bank the raspy powered on

Static WIFI address

How to use Rpi with wifi dongle and access it with fixed ip

the coming steps will lead to full control of the Rpi with wifi


first of all you have to connect to Rpi via cable connected to the local Router  (disconnect the wifi dongle ) and find its ip address to connect it via SSH . (these easy steps will be discussed later)

secondly after connection and opening SSH connection
go to /etc/network/interfaces via this command

       sudo nano /etc/network/interfaces


you will find these lines as image

change manual to static 
then add these lines and configure them according to your network settings

   allow-hotplug wlan0

   auto wlan0

   iface wlan0 inet static

   address 192.168.1.22

   netmask 255.255.255.0

   gateway 192.168.1.1


don't forget to put your own wanted ip instead of 192.168.1.22

the final look of the file /etc/network/interfaces will be 


press Ctrl+x then Enter to save the file and exit from nano editor 


now you have to enter the data of wifi name (ssid) and password
go to /etc/wpa_supplicant/wpa_supplicant.conf

       sudo nano /etc/wpa_supplicant/wpa_supplicant.conf


copy this Template to the file and add wifi name instead of "wifi_name" and wifi password instead of "wifi_password"


   network={
            ssid="wifi_name"
            psk="wifi_password"
            key_mgmt=WPA-PSK
   }

press Ctrl+x then Enter to save the file and exit from nano editor
then reboot the Rpi to active these settings you can use this line to reboot successfully

   sudo reboot ; exit




for any questions don't hesitate to ask to seek for answer together .



---------------------
hint : i still have problem with global connection with the Rpi with static ip 
the problem is with DNS put iam seeking for solution and i will publish it "Inshaa Allah".