Posts Tagged ‘Debian’

Another option you can employ is xkill. This is preinstalled in Ubuntu, but you can install it via the Terminal (which you can open with CTRL + ALT + T) if necessary. When called, xkill will enable you to close any desktop app. Install it with the following command:

sudo apt-get install xorg-xkill

Once this is done, run xkill by simply typing


Your mouse pointer will then display a cross (or a skull), and all you need to do is left-click on the offending application.

If it’s not possible to close your unresponsive app with any of these desktop-focused methods, the solution might be the command line…

Send Email when IP Address Changes

Posted: 6 Μαρτίου 2018 in linux
Ετικέτες: , , , ,

Εγκατάσταση msmtp σε  GNU/Linux για να στέλνουμε  emails από το  gmail

Βήμα 1: Κάνουμε εγκατάσταση μέσω τερματικού τα απαραίτητα πακέτα.

sudo apt-get install msmtp msmtp-mta

Βήμα 2: Δημιουργούμε ένα app password στο  Google λογαριασμό μας για το  msmtp

This (Step 2.* in this tutorial) was the missing piece of the puzzle which weren’t in any of the msmtp tutorials I did through. I found out about it in one of the Postfix tutorials where it was included after many hours of trial and error. Because at first, I thought the msmtp config file where was password field had to be filled with the same password with what you log in as a person to your account.

Go to: and log into the email account you want to start sending the emails.

Step 2.1: Select Security from the side menu and turn 2-Step Verification ON.

Step 2.2: After that click on App passwords

Step 2.3: Next up select Other (Custom name)

Step 2.4: Fill in the name as msmtp for example

Step 2.5: Get the password for your msmtp configuration file

Save this password to some notepad temporarily so you can copy & paste it later to a configuration file because once you click DONE you cannot see the password again. At least I have not found a way to re-open this popup.

Βήμα 3: Μπαίνουμε στο msmtprc

sudo nano /etc/msmtprc

Βήμα 4: Διαμορφώστε το msmtprc αρχείο

auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        ~/.msmtp.log
account        gmail
port           587
user           username
password       password
account default : gmail

To θα πρέπει να αλλαχτεί στο  config file με το email σας

To password με  τον κωδικό του app του google

Αλλάζουμε αν θέλουμε και το username

Βήμα 5:  Κάνουμε τεστ το email

echo "Message" | mail -s "Title"

Μετά την εντολή θα πρέπει να έχεις παραλάβει το email όπου έστειλες

Βήμα 6:  Κάνουμε εγκατάσταση το curl εάν δεν το έχουμε 

apt-get install curl

Βήμα 7:  Δημιουργούμε τα αρχεία 

1. Δημιουργούμε τα παρακάτω κενά αρχεία





2. The Script

#Script to report public IP address change
#By: Soultidis D. Christos

curl > /home/username/emailscript/erxeteip.txt

oldip=`cat /home/username/emailscript/oldip.txt`
erxeteip=`cat /home/username/emailscript/erxeteip.txt`

if [[ $erxeteip = $oldip ]]

    #echo $oldip > /home/username/emailscript/oldip.txt
    echo "Kamia allagi"

    echo $erxeteip > /home/username/emailscript/newip.txt
echo $erxeteip > /home/username/emailscript/oldip.txt

    cat /home/username/emailscript/newip.txt | mailx -s "Dynamic Public IP Address"


Αποθήκευσε το script  σαν εκτελέσιμο και βάλτο σε έναν φάκελο μαζί με τα άλλα αρχεία



Βήμα 8:  Cron και χρονική διάρκεια εκτέλεσης του script μας 

3. Cron
Πατάμε την παρακάτω εντολή στο τερματικό

crontab -e

Προσθέτουμε  αυτό ώστε να μπορεί να τρέχει το  script  ανα 5 λεπτά

*/5 * * * * /home/username/emailscript/ >/dev/null 2>&1

(Το 5 δηλώνει τα λεπτά , βάζουμε όσο θέλουμε εμείς)


Γράφουμε στο τερματικό :

pgrep cron 

Άμα δεν βλέπουμε αριθμό ο  cron δεν τρέχει. Έτσι πατάμε  sudo /etc/init.d/cron start  για να ξεκινήσει


Debian Linux Install OpenSSH SSHD Server

Posted: 24 Ιανουαρίου 2013 in linux
Ετικέτες: , , ,


How do I install OpenSSH sshd server under Debian GNU/Linux operating systems?

You need to use the apt-get or aptitude command to install OpenSSH server under Debian Linux. Open a terminal and type the following command to update package database as root user:
# apt-get update

Task: Install OpenSSH server Under Debian Linux

Type the following command:
# apt-get install openssh-server
Sample outputs:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  ssh-askpass rssh molly-guard ufw
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 318 kB of archives.
After this operation, 717 kB of additional disk space will be used.
Get:1 squeeze/main openssh-server amd64 1:5.5p1-6+squeeze1 [318 kB]
Fetched 318 kB in 3s (89.0 kB/s)
Preconfiguring packages ...
Selecting previously deselected package openssh-server.
(Reading database ... 153448 files and directories currently installed.)
Unpacking openssh-server (from .../openssh-server_1%3a5.5p1-6+squeeze1_amd64.deb) ...
Processing triggers for man-db ...
Setting up openssh-server (1:5.5p1-6+squeeze1) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Restarting OpenBSD Secure Shell server: sshd.

By default openssh will run on the TCP port 22. You can verify the same with the following command:
# netstat -tulpn | grep :22
Sample outputs:

tcp        0      0    *               LISTEN      3946/sshd
tcp6       0      0 :::22                   :::*                    LISTEN      3946/sshd

You can connect to the Openssh server, type:
$ ssh user@localhost
$ ssh user@sever-ip-here

How Do I Start / Stop / Restart OpenSSH Server Under Debian Linux?

Type the following commands as root user:
# service ssh stop
# service ssh start
# service ssh restart
# service ssh status

# /etc/init.d/ssh stop
# /etc/init.d/ssh start
# /etc/init.d/ssh restart
# /etc/init.d/ssh status

Sample session:

Fig.01: OpenSSH under Debian LinuxClick to enlarge the image

How Do I Open Port 22 At The Firewall Level?

Edit your firewall script and append the following rule to restrict access to

/sbin/iptables -A INPUT -s -m state --state NEW -p tcp --dport 22 -j ACCEPT

Save and close the file. OR, you can type the command as follows and save it to your firewall config file:

# /sbin/iptables -A INPUT -s -m state --state NEW -p tcp --dport 22 -j ACCEPT
# iptables-save > /path/to/your.firewall.conf

How Do I Configure and Secure OpenSSH Server under Debian Linux?

You need to edit the /etc/ssh/sshd_config file using the text editor such as vi, run:
# vi /etc/ssh/sshd_config
See this article which explains config option to tweak in order to improve OpenSSH server security.

Πηγή :