Page not found – ShopingServer Wiki http://wiki.shopingserver.com Tutorials and Articles About Technology and Gadgets Wed, 02 Sep 2020 02:21:13 +0000 en-US hourly 1 https://wordpress.org/?v=5.5.14 http://wiki.shopingserver.com/wp-content/uploads/2018/07/cropped-favicon-150x150.png Page not found – ShopingServer Wiki http://wiki.shopingserver.com 32 32 Debian 7 Wheezy: Install Flash Player http://wiki.shopingserver.com/debian-7-wheezy-install-flash-player/ http://wiki.shopingserver.com/debian-7-wheezy-install-flash-player/#respond Sat, 06 Jan 2018 10:21:22 +0000 http://wiki.shopingserver.com/?p=18597 I am a new Debian Linux version 7 user. I found out that Pandora player is not working due to Adobe flash player. How do I install and use flash player on Debian 7 with Firefox browser?

 

Adobe Flash Player is a multimedia plugin used to play video, games, streaming, and interactivity to Web pages. This how-to describes how to install the Adobe Flash Player (also known as the Macromedia Flash Player), on Debian 7 desktop or laptop systems.

Say, hello to flashplugin-nonfree package

This package acts as a wrapper packages and will download the Flash Player from Adobe. It is a Netscape/Mozilla type plugin. Any browser based on Netscape or Mozilla can use the Flash Player such as

Mozilla-Firefox

Iceweasel

Iceape

Galeon

Epiphany

Konqueror if konqueror-nsplugins is installed.

Installation

Open a terminal and edit the file /etc/apt/sources.list using a text editor and make sure following line exists:

deb ftp://ftp.debian.org/debian stable main contrib non-free

 

Save and close the file. Type the following command:

$ sudo apt-get update

 

Next, type the following apt-get command to install flash player plugin:

$ sudo apt-get install flashplugin-nonfree

 

OR

# apt-get install flashplugin-nonfree

 

Sample outputs:

Reading package lists… Done

Building dependency tree

Reading state information… Done

Suggested packages:

konqueror-nsplugins ttf-xfree86-nonfree hal

The following NEW packages will be installed:

flashplugin-nonfree

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Need to get 20.1 kB of archives.

After this operation, 181 kB of additional disk space will be used.

Get:1 http://mirrors.kernel.org/debian/ wheezy/contrib flashplugin-nonfree amd64 1:3.2 [20.1 kB]

Fetched 20.1 kB in 2s (8982 B/s)

Can t set locale; make sure $LC_* and $LANG are correct!

perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE =  en_IN:en ,

LC_ALL = (unset),

LC_CTYPE =  UTF-8 ,

LANG =  en_IN

are supported and installed on your system.

perl: warning: Falling back to the standard locale ( C ).

locale: Cannot set LC_CTYPE to default locale: No such file or directory

locale: Cannot set LC_ALL to default locale: No such file or directory

Selecting previously unselected package flashplugin-nonfree.

(Reading database … 193647 files and directories currently installed.)

Unpacking flashplugin-nonfree (from …/flashplugin-nonfree_1%3a3.2_amd64.deb) …

Processing triggers for man-db …

locale: Cannot set LC_CTYPE to default locale: No such file or directory

locale: Cannot set LC_ALL to default locale: No such file or directory

Processing triggers for hicolor-icon-theme …

Processing triggers for desktop-file-utils …

The Processing triggers for gnome-menus …

Setting up flashplugin-nonfree (1:3.2) …

–2013-06-05 15:55:53–  http://fpdownload.macromedia.com/get/flashplayer/pdc/11.2.202.285/install_flash_player_11_linux.x86_64.tar.gz

Resolving fpdownload.macromedia.com (fpdownload.macromedia.com)… 173.222.18.70

Connecting to fpdownload.macromedia.com (fpdownload.macromedia.com)|173.222.18.70|:80… connected.

HTTP request sent, awaiting response… 200 OK

Length: 7234643 (6.9M) [application/x-gzip]

Saving to: `/tmp/flashplugin-nonfree.i7GZyK1Oxl/install_flash_player_11_linux.x86_64.tar.gz

 

0K ………. ………. ………. ………. ……….  0%  529K 13s

50K ………. ………. ………. ………. ……….  1%  527K 13s

100K ………. ………. ………. ………. ……….  2%  544K 13s

150K ………. ………. ………. ………. ……….  2%  517K 13s

200K ………. ………. ………. ………. ……….  3%  523K 13s

250K ………. ………. ………. ………. ……….  4%  547K 13s

300K ………. ………. ………. ………. ……….  4%  521K 13s

350K ………. ………. ………. ………. ……….  5%  131K 17s

400K ………. ………. ………. ………. ……….  6%  857K 16s

450K ………. ………. ………. ………. ……….  7% 7.09M 15s

500K ………. ………. ………. ………. ……….  7% 7.93M 13s

550K ………. ………. ………. ………. ……….  8% 1.91M 12s

600K ………. ………. ………. ………. ……….  9%  510K 12s

650K ………. ………. ………. ………. ……….  9%  554K 12s

700K ………. ………. ………. ………. ………. 10%  523K 12s

750K ………. ………. ………. ………. ………. 11%  524K 12s

800K ………. ………. ………. ………. ………. 12%  538K 12s

850K ………. ………. ………. ………. ………. 12%  524K 12s

900K ………. ………. ………. ………. ………. 13%  540K 12s

950K ………. ………. ………. ………. ………. 14%  524K 11s

1000K ………. ………. ………. ………. ………. 14%  538K 11s

1050K ………. ………. ………. ………. ………. 15%  524K 11s

1100K ………. ………. ………. ………. ………. 16%  539K 11s

1150K ………. ………. ………. ………. ………. 16%  507K 11s

1200K ………. ………. ………. ………. ………. 17%  542K 11s

1250K ………. ………. ………. ………. ………. 18%  538K 11s

1300K ………. ………. ………. ………. ………. 19%  525K 11s

1350K ………. ………. ………. ………. ………. 19%  538K 11s

1400K ………. ………. ………. ………. ………. 20%  525K 11s

1450K ………. ………. ………. ………. ………. 21%  538K 11s

1500K ………. ………. ………. ………. ………. 21%  523K 10s

1550K ………. ………. ………. ………. ………. 22%  540K 10s

1600K ………. ………. ………. ………. ………. 23%  523K 10s

1650K ………. ………. ………. ………. ………. 24%  512K 10s

1700K ………. ………. ………. ………. ………. 24%  552K 10s

1750K ………. ………. ………. ………. ………. 25%  526K 10s

1800K ………. ………. ………. ………. ………. 26%  538K 10s

1850K ………. ………. ………. ………. ………. 26%  525K 10s

1900K ………. ………. ………. ………. ………. 27%  539K 10s

1950K ………. ………. ………. ………. ………. 28%  524K 10s

2000K ………. ………. ………. ………. ………. 29%  539K 9s

2050K ………. ………. ………. ………. ………. 29%  522K 9s

2100K ………. ………. ………. ………. ………. 30%  525K 9s

2150K ………. ………. ………. ………. ………. 31%  526K 9s

2200K ………. ………. ………. ………. ………. 31%  538K 9s

2250K ………. ………. ………. ………. ………. 32%  509K 9s

2300K ………. ………. ………. ………. ………. 33%  556K 9s

2350K ………. ………. ………. ………. ………. 33%  537K 9s

2400K ………. ………. ………. ………. ………. 34%  525K 9s

2450K ………. ………. ………. ………. ………. 35%  539K 9s

2500K ………. ………. ………. ………. ………. 36%  521K 9s

2550K ………. ………. ………. ………. ………. 36%  526K 8s

2600K ………. ………. ………. ………. ………. 37%  540K 8s

2650K ………. ………. ………. ………. ………. 38%  522K 8s

2700K ………. ………. ………. ………. ………. 38%  536K 8s

2750K ………. ………. ………. ………. ………. 39%  527K 8s

2800K ………. ………. ………. ………. ………. 40%  539K 8s

2850K ………. ………. ………. ………. ………. 41%  524K 8s

2900K ………. ………. ………. ………. ………. 41%  538K 8s

2950K ………. ………. ………. ………. ………. 42%  525K 8s

3000K ………. ………. ………. ………. ………. 43%  523K 8s

3050K ………. ………. ………. ………. ………. 43%  539K 7s

3100K ………. ………. ………. ………. ………. 44%  519K 7s

3150K ………. ………. ………. ………. ………. 45%  173K 8s

3200K ………. ………. ………. ………. ………. 46% 1.39M 7s

3250K ………. ………. ………. ………. ………. 46% 1.08M 7s

3300K ………. ………. ………. ………. ………. 47% 6.68M 7s

3350K ………. ………. ………. ………. ………. 48%  541K 7s

3400K ………. ………. ………. ………. ………. 48%  523K 7s

3450K ………. ………. ………. ………. ………. 49%  523K 7s

3500K ………. ………. ………. ………. ………. 50%  541K 7s

3550K ………. ………. ………. ………. ………. 50%  524K 7s

3600K ………. ………. ………. ………. ………. 51%  521K 6s

3650K ………. ………. ………. ………. ………. 52%  257K 6s

3700K ………. ………. ………. ………. ………. 53% 1.33M 6s

3750K ………. ………. ………. ………. ………. 53% 1018K 6s

3800K ………. ………. ………. ………. ………. 54%  539K 6s

3850K ………. ………. ………. ………. ………. 55%  524K 6s

3900K ………. ………. ………. ………. ………. 55%  315K 6s

3950K ………. ………. ………. ………. ………. 56% 1.67M 6s

4000K ………. ………. ………. ………. ………. 57%  523K 6s

4050K ………. ………. ………. ………. ………. 58%  423K 6s

4100K ………. ………. ………. ………. ………. 58%  532K 6s

4150K ………. ………. ………. ………. ………. 59%  458K 5s

4200K ………. ………. ………. ………. ………. 60%  505K 5s

4250K ………. ………. ………. ………. ………. 60%  444K 5s

4300K ………. ………. ………. ………. ………. 61%  472K 5s

4350K ………. ………. ………. ………. ………. 62%  412K 5s

4400K ………. ………. ………. ………. ………. 62%  490K 5s

4450K ………. ………. ………. ………. ………. 63%  508K 5s

4500K ………. ………. ………. ………. ………. 64%  539K 5s

4550K ………. ………. ………. ………. ………. 65%  411K 5s

4600K ………. ………. ………. ………. ………. 65%  548K 5s

4650K ………. ………. ………. ………. ………. 66%  451K 5s

4700K ………. ………. ………. ………. ………. 67%  512K 4s

4750K ………. ………. ………. ………. ………. 67%  478K 4s

4800K ………. ………. ………. ………. ………. 68%  401K 4s

4850K ………. ………. ………. ………. ………. 69%  418K 4s

4900K ………. ………. ………. ………. ………. 70%  470K 4s

4950K ………. ………. ………. ………. ………. 70%  530K 4s

5000K ………. ………. ………. ………. ………. 71%  524K 4s

5050K ………. ………. ………. ………. ………. 72%  539K 4s

5100K ………. ………. ………. ………. ………. 72%  493K 4s

5150K ………. ………. ………. ………. ………. 73%  441K 4s

5200K ………. ………. ………. ………. ………. 74%  486K 4s

5250K ………. ………. ………. ………. ………. 75%  516K 3s

5300K ………. ………. ………. ………. ………. 75%  440K 3s

5350K ………. ………. ………. ………. ………. 76%  396K 3s

5400K ………. ………. ………. ………. ………. 77%  402K 3s

5450K ………. ………. ………. ………. ………. 77%  497K 3s

5500K ………. ………. ………. ………. ………. 78%  541K 3s

5550K ………. ………. ………. ………. ………. 79%  523K 3s

5600K ………. ………. ………. ………. ………. 79%  533K 3s

5650K ………. ………. ………. ………. ………. 80%  466K 3s

5700K ………. ………. ………. ………. ………. 81%  435K 3s

5750K ………. ………. ………. ………. ………. 82%  476K 2s

5800K ………. ………. ………. ………. ………. 82%  507K 2s

5850K ………. ………. ………. ………. ………. 83%  421K 2s

5900K ………. ………. ………. ………. ………. 84%  484K 2s

5950K ………. ………. ………. ………. ………. 84%  418K 2s

6000K ………. ………. ………. ………. ………. 85%  446K 2s

6050K ………. ………. ………. ………. ………. 86%  529K 2s

6100K ………. ………. ………. ………. ………. 87%  523K 2s

6150K ………. ………. ………. ………. ………. 87%  523K 2s

6200K ………. ………. ………. ………. ………. 88%  437K 2s

6250K ………. ………. ………. ………. ………. 89%  502K 2s

6300K ………. ………. ………. ………. ………. 89%  454K 1s

6350K ………. ………. ………. ………. ………. 90%  514K 1s

6400K ………. ………. ………. ………. ………. 91%  403K 1s

6450K ………. ………. ………. ………. ………. 92%  565K 1s

6500K ………. ………. ………. ………. ………. 92%  400K 1s

6550K ………. ………. ………. ………. ………. 93%  463K 1s

6600K ………. ………. ………. ………. ………. 94%  514K 1s

6650K ………. ………. ………. ………. ………. 94%  540K 1s

6700K ………. ………. ………. ………. ………. 95%  402K 1s

6750K ………. ………. ………. ………. ………. 96%  633K 1s

6800K ………. ………. ………. ………. ………. 96%  407K 0s

6850K ………. ………. ………. ………. ………. 97%  521K 0s

6900K ………. ………. ………. ………. ………. 98%  514K 0s

6950K ………. ………. ………. ………. ………. 99%  460K 0s

7000K ………. ………. ………. ………. ………. 99%  397K 0s

7050K ………. …..                                      100%  442K=14s

 

2013-06-05 15:56:12 (504 KB/s) – `/tmp/flashplugin-nonfree.i7GZyK1Oxl/install_flash_player_11_linux.x86_64.tar.gz  saved [7234643/7234643]

How do I verify installation?

Close the browser. Open Firefox/Iceweasel and click on the Tools menu > choose Add-ons

Fig.01: Firefox/Iceweasel tools menu

 

Choose Plugins tab. You should see flasy player as follows in the list:

Fig.02: Verification for Flash player on Debian 7

 

Open a webrowser and visit the following youtube video for testing purpose:

And there you have it a working flash player for Firefox/Iceweasel on Debian Linux version 7.

 

 

]]>
http://wiki.shopingserver.com/debian-7-wheezy-install-flash-player/feed/ 0
Linux: Log Everyone Out Of The System http://wiki.shopingserver.com/linux-log-everyone-system/ http://wiki.shopingserver.com/linux-log-everyone-system/#respond Sat, 06 Jan 2018 10:06:18 +0000 http://wiki.shopingserver.com/?p=18579 I can login as root user on Debian or Ubuntu/RHEL/CentOS Linux based system. I need to log everyone off (all ssh users) to install new kernel and/or hardware. How do I do this on Linux?

What is the best way to logout ALL USERS remotely over the ssh based session in Linux like operating systems?

 

You need to use the following commands:

a] who or w command – Show who is logging on and what they are doing.

b] pkill command – Kill user session and forcefully logout of the system.

c] shutdown command – Arranges for the system to be bring down in a safe way.

Examples

Use the who command to see list of logged in users as follows:

# w

 

OR

# who

 

Sample outputs:

root     pts/0        Jul 29 13:53 (10.1.6.120)

nixcraft pts/1        Jul 29 12:30 (10.1.6.121)

sailee   pts/2        Jul 29 12:33 (10.1.6.121)

To force and logout nixcraft and sailee user, enter:

# pkill -KILL -u nixcraft

# pkill -KILL -u sailee

 

Alternatively, just try bash and friends kung-fu and save time:

### warning must be run as root or via sudo ###

who | awk  !/root/{ cmd= /sbin/pkill -KILL -u   $1; system(cmd)}

OR

### warning must be run as root or via sudo ###

Safe version 🙂 ###

who | awk  $1 !~ /root/{ cmd= /sbin/pkill -KILL -u   $1; system(cmd)}

Finally, you can shutdown the system as follows:

# shutdown -h now

Instead of killing all users one by one you can type the following shutdown command with the warning message:

# shutdown -h +10  Server is going down for maintenance in 10 minute. Please save ALL your work ASAP and logout of the system.

Please note that this method will not work with ftp/smtp/pop3 and all other user accounts on the server. I recommend that you set maintenance windows for your server when network traffic is at a minimum or when users/client computers were not engaged in other activities on the server. For example, week-end or the period between midnight and 3:00 a.m. can be set as maintenance windows for your system.

Recommended readings

See man pages – who(1),w(1),pkill(1),shutdown(8)

 

 

]]>
http://wiki.shopingserver.com/linux-log-everyone-system/feed/ 0
Debian / Ubuntu: apt-get Force Reinstall Package http://wiki.shopingserver.com/debian-ubuntu-apt-get-force-reinstall-package/ http://wiki.shopingserver.com/debian-ubuntu-apt-get-force-reinstall-package/#respond Sat, 06 Jan 2018 10:02:32 +0000 http://wiki.shopingserver.com/?p=18573 I am a new Debian Linux v.7.x / Ubuntu Linux LTS user. How do I reinstall a package using apt-get command line?

 

The Advanced Packaging Tool (APT) works on both Debian / Ubuntu and it can handle the installation and removal of software. You need use apt-get command as follows to forcefully reinstall package. The syntax is:

apt-get –reinstall install PackageNameHere

OR

apt-get –reinstall install Package1 Package2

The –reinstall option re-install packages that are already installed and at the newest version.

Pro tip: Backup configuration files before you reinstall packages. For example, if you are reinstalling nginx web server package, backup /etc/nginx/ with cp command i.e. mkdir /root/nginx.mmddyyyy/; cp -avr /etc/nginx/* /root/nginx.mmddyyy/

Examples

The following command will reinstall rsync package. Open a terminal and then type:

$ sudo apt-get –reinstall install rsync

 

OR

# apt-get –reinstall install rsync

 

Sample outputs:

Fig.01: Debian / Ubuntu Linux reinstall a package using apt-get command

If above method failed for you, try the following syntax. Make sure you backup config file before typing the following commands. Please note that the –purge option is identical to remove except that packages are removed and purged including any configuration files are deleted too.

sudo apt-get –purge remove package1

sudo apt-get install package1

See also

See man pages for more info – apt-get(8),dpkg(1),cp(1)

 

 

]]>
http://wiki.shopingserver.com/debian-ubuntu-apt-get-force-reinstall-package/feed/ 0
W: TMPDIR is Mounted noexec, Will Not Cache Run Scripts Error and Solution http://wiki.shopingserver.com/w-tmpdir-mounted-noexec-will-not-cache-run-scripts-error-solution/ http://wiki.shopingserver.com/w-tmpdir-mounted-noexec-will-not-cache-run-scripts-error-solution/#respond Sat, 06 Jan 2018 10:01:17 +0000 http://wiki.shopingserver.com/?p=18571 I mount /tmp with nodev, nosuid, and noexec options to increase the security of my Linux based web server. And, whenever I ran apt-get install or apt-get upgrade command, I am getting the following error:

apt-get install linux-generic linux-headers-generic linux-image-generic

…..

….

..

Generating grub.cfg …

Found linux image: /boot/vmlinuz-3.2.0-43-generic

Found initrd image: /boot/initrd.img-3.2.0-43-generic

….

ldconfig deferred processing now taking place

Processing triggers for initramfs-tools …

update-initramfs: Generating /boot/initrd.img-3.2.0-43-generic

W: TMPDIR is mounted noexec, will not cache run scripts.

….

How do I fix this problem without compromising security of the data or web-server?

 

You can make /tmp non-executable by setting the following two flags in /etc/fstab file:

noexec – Do not allow direct execution of any binaries or scripts on the mounted filesystem at /tmp.

nosuid – Do not allow SUID or SGID bits to take effect.

nodev – Do not interpret character or block special devices on the file system.

This will safeguard your server against various attacks. But, apt-get upgrade command may fail with the following message:

W: TMPDIR is mounted noexec, will not cache run scripts.

 

apt-get command use /tmp to place scripts and scripts can not execute due to noexec flag on /tmp. To fix your problem edit or create the file /etc/apt/apt.conf (, enter:

# vi /etc/apt/apt.conf

 

OR

$ sudo vi /etc/apt/apt.conf

 

Sample outputs:

DPkg::Pre-Invoke{ mount -o remount,exec /tmp ;};

DPkg::Post-Invoke { mount -o remount,rw,noexec,nosuid,nodev /tmp ;};

Save and close the file. The apt.conf is the main configuration file for the APT suite of tools. The commands are invoked in order using /bin/sh, should any fail APT will abort. Where,

DPkg::Pre-Invoke{ mount -o remount,exec /tmp ;}; – This is a list of shell commands to run before dpkg command. In this example, remove noexec flag from /tmp, so that script can get executed.

DPkg::Post-Invoke { mount -o remount,rw,noexec,nosuid,nodev /tmp ;}; – This is a list of shell commands to run after dpkg. In this example, set noexec and other security flag on /tmp

How do I reinstall and rexecute packages again?

Once you applied the solution as describe above, you can just reinstall the package as follows to run the scripts:

$ sudo apt-get –reinstall install linux-generic linux-headers-generic linux-image-generic

 

In this example,

First, mount -o remount,exec /tmp command will run by apt-get as defined in apt.conf to relax permission on /tmp.

Next, your actual apt-get/dpkg command will get executed to reinstall kernel packages.

Finally mount -o remount,rw,noexec,nosuid,nodev /tmp command will run by apt-get to secure your /tmp.

See also

Man pages – apt.conf(5),apt-get(8),dpkg(1)

 

 

]]>
http://wiki.shopingserver.com/w-tmpdir-mounted-noexec-will-not-cache-run-scripts-error-solution/feed/ 0
Linux / Unix: Shell Script Find Out In Which Directory Script File Resides http://wiki.shopingserver.com/linux-unix-shell-script-find-directory-script-file-resides/ http://wiki.shopingserver.com/linux-unix-shell-script-find-directory-script-file-resides/#respond Sat, 06 Jan 2018 09:58:13 +0000 http://wiki.shopingserver.com/?p=18567 I need to find out in which directory my bash script resides so that I can read config file called .backup .ignore .target. For example, if my script resides in >/home/foo/script.sh, I need to read /home/foo/.{backup,ignore,target} files.

How do I find out the current directory location and shell script directory location in Bash running on Linux or Unix like operating systems?

 

You can use any one of the following method to find out the portion of pathname:

basename command – Display filename portion of pathname.

dirname command – Display directory portion of pathname.

Bash parameter substitution.

$0 expands to the name of the shell or shell script.

Examples: Shell script find out which directory the script file resides

The following example display directory path or portion of /home/nixcraft/scripts/foo.sh:

dirname /home/nixcraft/scripts/foo.sh

Sample outputs:

/home/nixcraft/scripts

The following line sets the shell variable i to /home/nixcraft/scripts:

i=dirname /home/nixcraft/scripts/foo.sh

echo  $i

OR

i=$(dirname /home/nixcraft/scripts/foo.sh)

echo  $i

In bash script use $0 instead of /home/nixcraft/scripts/foo.sh:

#!/bin/bash

script= $0

basename= $(dirname $script)

 

echo  Script name $script resides in $basename directory.

Sample outputs:

Script name /tmp/test.sh resides in /tmp directory.

Using bash shell ${var%pattern} syntax

To Remove from shortest rear (end) pattern use the following syntax:

var=${path%/*}

For example:

x= /Users/nixcraft/scripts/bar.sh

echo  ${x%/*}

y= ${x%/*}

echo  $y

An updated version of the above script:

#!/bin/bash

# Purpose : Linux / Unix shell script find out which directory this script file resides

# Author : nixCraft <http://www.cyberciti.biz> under GPL v2.x+

# ————————————————————————————-

script= $0

basename= ${script%/*}

config1= ${basename}/.backup

config2= ${basename}/.ignore

config3= ${basename}/.target

 

echo  Script name $script resides in $basename directory.

echo  Reading config file $config1 $config2 $config3, please wait…

Run it as:

$ chmod +x /tmp/test.sh

$ /tmp/test.sh

 

Sample outputs:

Fig.01 Sample run from test.sh

A note about finding physical or real path

You may not get a real physical path and real path may be a symbolic link. To get physical path use realpath command. The realpath command uses the realpath() function to resolve all symbolic links, extra / characters and references to /./ and /../ in path. This is useful for shell scripting and security related applications.

Another recommended option is to use the readlink command to display value of a symbolic link or canonical file name:

#!/bin/bash

# Purpose : Linux / Unix shell script find out which directory this script file resides

# Author : nixCraft <http://www.cyberciti.biz> under GPL v2.x+

# ————————————————————————————-

 

Who am i? ##

Get real path ##

_script= $(readlink -f ${BASH_SOURCE[0]})

 

Delete last component from $_script ##

_mydir= $(dirname $_script)

 

Delete /path/to/dir/ component from $_script ##

_myfile= $(basename $_script)

echo  Script : $_script

echo  Directory portion of $_script : $_mydir

echo  Filename portion of $_script : $_myfile

Save and close the file. Run it as follows:

./demo.bash

cd /home/vivek/

../../tmp/demo.bash

/tmp/demo.bash

Sample outputs:

Fig.02: Finding real path

See also

See man pages for more info – basename(1), dirname(1), bash(1)

 

 

]]>
http://wiki.shopingserver.com/linux-unix-shell-script-find-directory-script-file-resides/feed/ 0
OpenSSH Config File Examples http://wiki.shopingserver.com/openssh-config-file-examples-2/ http://wiki.shopingserver.com/openssh-config-file-examples-2/#respond Sat, 06 Jan 2018 09:39:40 +0000 http://wiki.shopingserver.com/?p=18545 H

ow do I create and setup an OpenSSH config file to create shortcuts for servers I frequently access under Linux or Unix desktop operating systems?

 

A global or local configuration file for SSH client can create shortcuts for sshd server including advanced ssh client options. You can configure your OpenSSH ssh client using various files as follows to save time and typing frequently used ssh client command line options such as port, user, hostname, identity-file and much more:

System-wide SSH client configuration files

/etc/ssh/ssh_config : This files set the default configuration for all users of OpenSSH clients on that desktop/laptop and it must be readable by all users on the system.

User-specific SSH client configuration files

~/.ssh/config or $HOME/.ssh/config : This is user’s own configuration file which, overrides the settings in the global client configuration file, /etc/ssh/ssh_config.

~/.ssh/config file rules

The rules are as follows to create an ssh config file:

You need to edit ~/.ssh/config with a text editor such as vi.

One config parameter per line is allowed in the configuration file with the parameter name followed by its value or values. The syntax is:

config value

config1 value1 value2

You can use an equal sign (=) instead of whitespace between the parameter name and the values.

config=value

config1=value1 value2

All empty lines are ignored.

All lines starting with the hash (#) are ignored.

All values are case-sensitive, but parameter names are not.

Tip : If this is a brand new Linux, Apple OS X/Unix box, or if you have never used ssh before create the ~/.ssh/ directory first using the following syntax:

mkdir -p $HOME/.ssh

chmod 0700 $HOME/.ssh

Examples

For demonstration purpose my sample setup is as follows:

Local desktop client – Apple OS X or Ubuntu Linux.

Remote Unix server – OpenBSD server running latest OpenSSH server.

Remote OpenSSH server ip/host: 75.126.153.206 (server1.cyberciti.biz)

Remote OpenSSH server user: nixcraft

Remote OpenSSH port: 4242

Local ssh private key file path : /nfs/shared/users/nixcraft/keys/server1/id_rsa

Based upon the above information my ssh command is as follows:

$ ssh -i /nfs/shared/users/nixcraft/keys/server1/id_rsa -p 4242 nixcraft@server1.cyberciti.biz

 

OR

$ ssh -i /nfs/shared/users/nixcraft/keys/server1/id_rsa -p 4242 -l nixcraft server1.cyberciti.biz

You can avoid typing all of the ssh command parameters while logging into a remote machine and/or for executing commands on a remote machine. All you have to do is create an ssh config file. Open the Terminal application and create your config file by typing the following command:

edit file in $HOME dir

 

vi ~/.ssh/config

OR

edit file in $HOME dir

 

vi $HOME/.ssh/config

Add/Append the following config option for a shortcut to server1 as per our sample setup:

Host server1

HostName server1.cyberciti.biz

User nixcraft

Port 4242

IdentityFile /nfs/shared/users/nixcraft/keys/server1/id_rsa

Save and close the file. To open your new SSH session to server1.cyberciti.biz by typing the following command:

$ ssh server1

Adding another host

Append the following to your ~/.ssh/config file:

Host nas01

HostName 192.168.1.100

User root

IdentityFile ~/.ssh/nas01.key

You can simply type:

$ ssh nas01

Putting it all together

Here is my sample ~/.ssh/config file that explains and create, design, and evaluate different needs for remote access using ssh client:

default for all ##

Host *

ForwardAgent no

ForwardX11 no

ForwardX11Trusted yes

User nixcraft

Port 22

Protocol 2

ServerAliveInterval 60

ServerAliveCountMax 30

 

override as per host ##

Host server1

HostName server1.cyberciti.biz

User nixcraft

Port 4242

IdentityFile /nfs/shared/users/nixcraft/keys/server1/id_rsa

 

Home nas server ##

Host nas01

HostName 192.168.1.100

User root

IdentityFile ~/.ssh/nas01.key

 

Login AWS Cloud ##

Host aws.apache

HostName 1.2.3.4

User wwwdata

IdentityFile ~/.ssh/aws.apache.key

 

Login to internal lan server at 192.168.0.251 via our public uk office ssh based gateway using ##

$ ssh uk.gw.lan ##

Host uk.gw.lan uk.lan

HostName 192.168.0.251

User nixcraft

ProxyCommand  ssh nixcraft@gateway.uk.cyberciti.biz nc %h %p 2> /dev/null

 

Our Us Proxy Server ##

Forward all local port 3128 traffic to port 3128 on the remote vps1.cyberciti.biz server ##

$ ssh -f -N  proxyus ##

Host proxyus

HostName vps1.cyberciti.biz

User breakfree

IdentityFile ~/.ssh/vps1.cyberciti.biz.key

LocalForward 3128 127.0.0.1:3128

Understanding ~/.ssh/config entries

Host : Defines for which host or hosts the configuration section applies. The section ends with a new Host section or the end of the file. A single * as a pattern can be used to provide global defaults for all hosts.

HostName : Specifies the real host name to log into. Numeric IP addresses are also permitted.

User : Defines the username for the SSH connection.

IdentityFile : Specifies a file from which the user’s DSA, ECDSA or DSA authentication identity is read. The default is ~/.ssh/identity for protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/id_rsa for protocol version 2.

ProxyCommand : Specifies the command to use to connect to the server. The command string extends to the end of the line, and is executed with the user’s shell. In the command string, any occurrence of %h will be substituted by the host name to connect, %p by the port, and %r by the remote user name. The command can be basically anything, and should read from its standard input and write to its standard output. This directive is useful in conjunction with nc(1) and its proxy support. For example, the following directive would connect via an HTTP proxy at 192.1.0.253:

ProxyCommand /usr/bin/nc -X connect -x 192.1.0.253:3128 %h %p

LocalForward : Specifies that a TCP port on the local machine be forwarded over the secure channel to the specified host and port from the remote machine. The first argument must be [bind_address:]port and the second argument must be host:hostport.

Port : Specifies the port number to connect on the remote host.

Protocol : Specifies the protocol versions ssh(1) should support in order of preference. The possible values are 1 and 2.

ServerAliveInterval : Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server. See blogpost “Open SSH Server connection drops out after few or N minutes of inactivity” for more information.

ServerAliveCountMax : Sets the number of server alive messages which may be sent without ssh(1) receiving any messages back from the server. If this threshold is reached while server alive messages are being sent, ssh will disconnect from the server, terminating the session.

Speed up ssh session

Multiplexing is nothing but send more than one ssh connection over a single connection. OpenSSH can reuse an existing TCP connection for multiple concurrent SSH sessions. This results into reduction of the overhead of creating new TCP connections. Update your ~/.ssh/config:

Host server1

HostName server1.cyberciti.biz

ControlPath ~/.ssh/controlmasters/%r@%h:%p

ControlMaster auto

See “Linux / Unix: OpenSSH Multiplexer To Speed Up OpenSSH Connections” for more info. In this example, I go through one host to reach another server i.e. jump host using ProxyCommand:

~/.ssh/config ##

Host internal

HostName 192.168.1.100

User vivek

ProxyCommand ssh vivek@vpn.nixcraft.net.in -W %h:%p

ControlPath ~/.ssh/controlmasters/%r@%h:%p

ControlMaster auto

For more info see following tutorials:

How To Reuse SSH Connection To Speed Up Remote Login Process Using Multiplexing

How To Setup SSH Keys on a Linux / Unix System

A note about shell aliases (outdated method)

WARNING! This bash shell aliased based setup may work out for you. However, I recommend that you use ~/.ssh/config file for better results in a long run. SSH config file is more advanced and elegant solutions. The alias command only used here for demo purpose and it is here due to historical reasons.

An alias is nothing but shortcut to commands and you can create the alias use the following syntax in your ~/.bashrc file:

create a new bash shell alias as follow ##

 

alias server1= ssh -i /nfs/shared/users/nixcraft/keys/server1/id_rsa -p 4242 nixcraft@server1.cyberciti.biz

Then, to ssh into the server1, instead of typing full ssh -i /nfs/shared/users/nixcraft/keys/server1/id_rsa -p 4242 nixcraft@server1.cyberciti.biz command, you would only have to type the command ‘server1’ and press the [ENTER] key:

$ server1

References

See ssh_config(5) for more information on syntax and some of the other available options.

Top 20 OpenSSH Server Best Security Practices

 

 

]]>
http://wiki.shopingserver.com/openssh-config-file-examples-2/feed/ 0
OpenSSH Config File Examples http://wiki.shopingserver.com/openssh-config-file-examples/ http://wiki.shopingserver.com/openssh-config-file-examples/#respond Sat, 06 Jan 2018 09:36:00 +0000 http://wiki.shopingserver.com/?p=18541 How do I create and setup an OpenSSH config file to create shortcuts for servers I frequently access under Linux or Unix desktop operating systems?

A global or local configuration file for SSH client can create shortcuts for sshd server including advanced ssh client options. You can configure your OpenSSH ssh client using various files as follows to save time and typing frequently used ssh client command line options such as port, user, hostname, identity-file and much more:

System-wide SSH client configuration files

/etc/ssh/ssh_config : This files set the default configuration for all users of OpenSSH clients on that desktop/laptop and it must be readable by all users on the system.

User-specific SSH client configuration files

~/.ssh/config or $HOME/.ssh/config : This is user’s own configuration file which, overrides the settings in the global client configuration file, /etc/ssh/ssh_config.

~/.ssh/config file rules

The rules are as follows to create an ssh config file:

You need to edit ~/.ssh/config with a text editor such as vi.

One config parameter per line is allowed in the configuration file with the parameter name followed by its value or values. The syntax is:

config value

config1 value1 value2

You can use an equal sign (=) instead of whitespace between the parameter name and the values.

config=value

config1=value1 value2

 

 

 

 

Tip : If this is a brand new Linux, Apple OS X/Unix box, or if you have never used ssh before create the ~/.ssh/ directory first using the following syntax:

mkdir -p $HOME/.ssh

chmod 0700 $HOME/.ssh

Examples

For demonstration purpose my sample setup is as follows:

Local desktop client – Apple OS X or Ubuntu Linux.

 

 

 

 

 

Local ssh private key file path : /nfs/shared/users/nixcraft/keys/server1/id_rsa

Based upon the above information my ssh command is as follows:

$ ssh -i /nfs/shared/users/nixcraft/keys/server1/id_rsa -p 4242 nixcraft@server1.cyberciti.biz

 

OR

$ ssh -i /nfs/shared/users/nixcraft/keys/server1/id_rsa -p 4242 -l nixcraft server1.cyberciti.biz

You can avoid typing all of the ssh command parameters while logging into a remote machine and/or for executing commands on a remote machine. All you have to do is create an ssh config file. Open the Terminal application and create your config file by typing the following command:

edit file in $HOME dir

 

vi ~/.ssh/config

OR

edit file in $HOME dir

 

vi $HOME/.ssh/config

Add/Append the following config option for a shortcut to server1 as per our sample setup:

Host server1

HostName server1.cyberciti.biz

User nixcraft

Port 4242

IdentityFile /nfs/shared/users/nixcraft/keys/server1/id_rsa

Save and close the file. To open your new SSH session to server1.cyberciti.biz by typing the following command:

$ ssh server1

Adding another host

Append the following to your ~/.ssh/config file:

Host nas01

HostName 192.168.1.100

User root

IdentityFile ~/.ssh/nas01.key

You can simply type:

$ ssh nas01

Putting it all together

Here is my sample ~/.ssh/config file that explains and create, design, and evaluate different needs for remote access using ssh client:

default for all ##

Host *

ForwardAgent no

ForwardX11 no

ForwardX11Trusted yes

User nixcraft

Port 22

Protocol 2

ServerAliveInterval 60

ServerAliveCountMax 30

 

override as per host ##

Host server1

HostName server1.cyberciti.biz

User nixcraft

Port 4242

IdentityFile /nfs/shared/users/nixcraft/keys/server1/id_rsa

 

Home nas server ##

Host nas01

HostName 192.168.1.100

User root

IdentityFile ~/.ssh/nas01.key

 

Login AWS Cloud ##

Host aws.apache

HostName 1.2.3.4

User wwwdata

IdentityFile ~/.ssh/aws.apache.key

 

Login to internal lan server at 192.168.0.251 via our public uk office ssh based gateway using ##

$ ssh uk.gw.lan ##

Host uk.gw.lan uk.lan

HostName 192.168.0.251

User nixcraft

ProxyCommand  ssh nixcraft@gateway.uk.cyberciti.biz nc %h %p 2> /dev/null

 

Our Us Proxy Server ##

Forward all local port 3128 traffic to port 3128 on the remote vps1.cyberciti.biz server ##

$ ssh -f -N  proxyus ##

Host proxyus

HostName vps1.cyberciti.biz

User breakfree

IdentityFile ~/.ssh/vps1.cyberciti.biz.key

LocalForward 3128 127.0.0.1:3128

Understanding ~/.ssh/config entries

Host : Defines for which host or hosts the configuration section applies. The section ends with a new Host section or the end of the file. A single * as a pattern can be used to provide global defaults for all hosts.

HostName : Specifies the real host name to log into. Numeric IP addresses are also permitted.

User : Defines the username for the SSH connection.

IdentityFile : Specifies a file from which the user’s DSA, ECDSA or DSA authentication identity is read. The default is ~/.ssh/identity for protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/id_rsa for protocol version 2.

ProxyCommand : Specifies the command to use to connect to the server. The command string extends to the end of the line, and is executed with the user’s shell. In the command string, any occurrence of %h will be substituted by the host name to connect, %p by the port, and %r by the remote user name. The command can be basically anything, and should read from its standard input and write to its standard output. This directive is useful in conjunction with nc(1) and its proxy support. For example, the following directive would connect via an HTTP proxy at 192.1.0.253:

ProxyCommand /usr/bin/nc -X connect -x 192.1.0.253:3128 %h %p

LocalForward : Specifies that a TCP port on the local machine be forwarded over the secure channel to the specified host and port from the remote machine. The first argument must be [bind_address:]port and the second argument must be host:hostport.

Port : Specifies the port number to connect on the remote host.

Protocol : Specifies the protocol versions ssh(1) should support in order of preference. The possible values are 1 and 2.

ServerAliveInterval : Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server. See blogpost “Open SSH Server connection drops out after few or N minutes of inactivity” for more information.

ServerAliveCountMax : Sets the number of server alive messages which may be sent without ssh(1) receiving any messages back from the server. If this threshold is reached while server alive messages are being sent, ssh will disconnect from the server, terminating the session.

Speed up ssh session

Multiplexing is nothing but send more than one ssh connection over a single connection. OpenSSH can reuse an existing TCP connection for multiple concurrent SSH sessions. This results into reduction of the overhead of creating new TCP connections. Update your ~/.ssh/config:

Host server1

HostName server1.cyberciti.biz

ControlPath ~/.ssh/controlmasters/%r@%h:%p

ControlMaster auto

See “Linux / Unix: OpenSSH Multiplexer To Speed Up OpenSSH Connections” for more info. In this example, I go through one host to reach another server i.e. jump host using ProxyCommand:

~/.ssh/config ##

Host internal

HostName 192.168.1.100

User vivek

ProxyCommand ssh vivek@vpn.nixcraft.net.in -W %h:%p

ControlPath ~/.ssh/controlmasters/%r@%h:%p

ControlMaster auto

For more info see following tutorials:

How To Reuse SSH Connection To Speed Up Remote Login Process Using Multiplexing

How To Setup SSH Keys on a Linux / Unix System

A note about shell aliases (outdated method)

WARNING! This bash shell aliased based setup may work out for you.

However,

I recommend that you use ~/.ssh/config file for better results in a long run. SSH config file is more advanced and elegant solutions.

The alias command only used here for demo purpose and it is here due to historical reasons.

An alias is nothing but shortcut to commands and you can create the alias use the following syntax in your ~/.bashrc file:

create a new bash shell alias as follow ##

 

alias server1= ssh -i /nfs/shared/users/nixcraft/keys/server1/id_rsa -p 4242 nixcraft@server1.cyberciti.biz

Then, to ssh into the server1, instead of typing full ssh -i /nfs/shared/users/nixcraft/keys/server1/id_rsa -p 4242 nixcraft@server1.cyberciti.biz command, you would only have to type the command ‘server1’ and press the [ENTER] key:

$ server1

References

See ssh_config(5) for more information on syntax and some of the other available options.

Top 20 OpenSSH Server Best Security Practices

 

 

]]>
http://wiki.shopingserver.com/openssh-config-file-examples/feed/ 0
Debian / Ubuntu: Install Duplicity For Encrypted Backup In Cloud http://wiki.shopingserver.com/debian-ubuntu-install-duplicity-encrypted-backup-cloud/ http://wiki.shopingserver.com/debian-ubuntu-install-duplicity-encrypted-backup-cloud/#respond Sat, 06 Jan 2018 09:32:20 +0000 http://wiki.shopingserver.com/?p=18537 My cloud based backup service provider has ssh access to the backup system. How do I install and configure duplicity software for remote backups in incremental and encrypted format on Debian or Ubuntu Linux based desktop / laptop / server?

 

Duplicity is a piece of software which provides easy encrypted versioned remote backup of files requiring little of the remote server. It does this using GnuPG, tar, and rdiff. To transmit data it can use ssh/scp, local file access, rsync, ftp, and Amazon S3.

You also need to setup a passphrase. A passphrase is a sequence of words or other text used to control access to a computer system, program or data.

A passphrase is similar to a password in usage, but is generally longer for added security. Passphrases are often used to control both access to, and operation of, cryptographic programs and systems.

Passphrases are particularly applicable to systems that use the passphrase as an encryption key. I strongly recommend that you setup a passphrase for your ssh-keys.

Install duplicity on Debian / Ubuntu Linux

Open the terminal and type the following command (Red hat and friends see our previous faq “Install duplicity on RHEL/CentOS based systems” for more information):

$ sudo apt-get install duplicity

 

OR

# apt-get install duplicity

 

Sample outputs:

Reading package lists… Done

Building dependency tree

Reading state information… Done

The following extra packages will be installed:

librsync1 python-crypto python-gnupginterface python-paramiko

Suggested packages:

python-boto ncftp python-pexpect python-cloudfiles python-gdata tahoe-lafs

python-crypto-dbg python-crypto-doc

The following NEW packages will be installed:

duplicity librsync1 python-crypto python-gnupginterface python-paramiko

0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.

Need to get 1,735 kB of archives.

After this operation, 10.4 MB of additional disk space will be used.

Do you want to continue [Y/n]? y

Get:1 http://mirrors.kernel.org/debian/ stable/main librsync1 amd64 0.9.7-9 [72.1 kB]

Get:2 http://mirrors.kernel.org/debian/ stable/main python-gnupginterface all 0.3.2-9.1 [21.0 kB]

Get:3 http://mirrors.kernel.org/debian/ stable/main duplicity amd64 0.6.18-3 [309 kB]

Get:4 http://mirrors.kernel.org/debian/ stable/main python-crypto amd64 2.6-4 [524 kB]

Get:5 http://mirrors.kernel.org/debian/ stable/main python-paramiko all 1.7.7.1-3.1 [809 kB]

Fetched 1,735 kB in 6s (262 kB/s)

Selecting previously unselected package librsync1:amd64.

(Reading database … 36532 files and directories currently installed.)

Unpacking librsync1:amd64 (from …/librsync1_0.9.7-9_amd64.deb) …

Selecting previously unselected package python-gnupginterface.

Unpacking python-gnupginterface (from …/python-gnupginterface_0.3.2-9.1_all.deb) …

Selecting previously unselected package duplicity.

Unpacking duplicity (from …/duplicity_0.6.18-3_amd64.deb) …

Selecting previously unselected package python-crypto.

Unpacking python-crypto (from …/python-crypto_2.6-4_amd64.deb) …

Selecting previously unselected package python-paramiko.

Unpacking python-paramiko (from …/python-paramiko_1.7.7.1-3.1_all.deb) …

Processing triggers for man-db …

 

 

 

 

 

 

Processing triggers for python-support …

How do I create SSH keys?

To run automated backups, you must set password-less SSH connections using an SSH keys. Use ssh-keygen command to create ssh-keys:

ssh-keygen -t rsa

Skip a passphrase (not recommend)

If you trust your local system/server/latop/desktop do not enter a passphrase. Just hit enter twice and set an empty passphrase. See the following step-by-step guide for detailed information on setting up ssh keys:

Howto Linux / UNIX setup SSH with DSA public key authentication (password less login)

Howto use multiple SSH keys for password less login?

Setup a passphrase for ssh keys (recommend)

If you are paranoid, set a passphrase when prompted and install keychain to setup password less login:

$ sudo apt-get install keychain

 

Edit your ~/.bash_profile, enter:

vi $HOME/.bash_profile

 

Append the following keychain config directives:

Note –clear option is a security feature ##

/usr/bin/keychain –clear  $HOME/.ssh/id_rsa

source $HOME/.keychain/$HOSTNAME-sh

Save and close the file. See our faq: “keychain: Set Up Secure Passwordless SSH Access For Backup Scripts” for more information.

How do I create a GPG keys?

Install GNU privacy guard – a free PGP replacement:

# apt-get install gnupg

 

OR

$ sudo apt-get install gnupg

 

Type the following command to create a GPG key to encrypt backups:

# gpg –gen-key

 

Sample outputs:

gpg (GnuPG) 1.4.12; Copyright (C) 2012 Free Software Foundation, Inc.

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

 

gpg: keyring `/root/.gnupg/secring.gpg  created

Please select what kind of key you want:

(1) RSA and RSA (default)

(2) DSA and Elgamal

(3) DSA (sign only)

(4) RSA (sign only)

Your selection? 1

RSA keys may be between 1024 and 4096 bits long.

What keysize do you want? (2048) 4096

Requested keysize is 4096 bits

Please specify how long the key should be valid.

0 = key does not expire

<n>  = key expires in n days

<n>w = key expires in n weeks

<n>m = key expires in n months

<n>y = key expires in n years

Key is valid for? (0) 0

Key does not expire at all

Is this correct? (y/N) y

 

You need a user ID to identify your key; the software constructs the user ID

from the Real Name, Comment and Email Address in this form:

Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>

 

Real name: Home Nas Server

Email address: root@nas01

Comment: Home Nas Server Backup

You selected this USER-ID:

Home Nas Server (Home Nas Server Backup) <root@nas01>

 

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O

You need a Passphrase to protect your secret key.

To list your gpg keys, run:

# gpg –list-keys

 

Sample outputs:

/root/.gnupg/pubring.gpg


pub   4096R/4AABBCC7 2013-10-04

uid                  Home Nas Server (Home Nas Server Backup) <root@nas01>

sub   4096R/12345678 2013-10-04

You need to note down the public key 4AABBCC7.

How do I backup files?

The following example use scp to backup /home/nixcraft/ to ~/backups on the cloud.example.com system:

duplicity /home/nixcraft/ scp://user@cloud.example.com/backups

Exclude the files from backup

The following command will backup the / (whole root file system) but excludes /tmp, /proc, /nas, /jails, and /mnt directories from backup:

duplicity –exclude /tmp/ –exclude /proc/ –exclude /nas/ \

–exclude /jails/ –exclude /mnt/ / scp://user@cloud.example.com/backups

Include the files in backup

The following command will backup only the /home/, /root/, /etc/, and /var/spool/cron/ directories under root (/) file system using the –include option:

duplicity –include /home/ –include /root –include /etc/ \

–include /var/spool/cron/ –exclude  **  / scp://user@cloud.example.com/backups

Encrypted backup commands

When backing up, encrypt to the given public key, instead of using symmetric (traditional) encryption. You need to use the –encrypt-key option as follows. To find out your gpg key-id use the following command:

gpg –list-keys

Full backup duplicity command

To make full encrypted backup, enter:

duplicity full –encrypt-key= 4AABBCC7  /home/nixcraft/ scp://userNameHere@cloud.example.com/backups

Incremental backup duplicity command

To make incremental encrypted backup, enter:

duplicity incr –encrypt-key= 4AABBCC7  /home/nixcraft/ scp://userNameHere@cloud.example.com/backups

List the files stored in the archive

To see the files currently backed up in the archive, enter:

duplicity list-current-files –encrypt-key= 4AABBCC7  scp://userNameHere@cloud.example.com/backups

Verify backup duplicity command

You can verify backup with the following command:

duplicity verify –encrypt-key= 4AABBCC7  scp://userNameHere@cloud.example.com/backups /home/nixcraft

Rotate backup duplicity command

You can delete all backup sets older than the given time. Now suppose you want to retain 60 days of backup and remove files older than 60 days, enter:

duplicity remove-older-than 60D –encrypt-key= 4AABBCC7  –force scp://userNameHere@cloud.example.com/backups

Pass the remove-all-but-n-full count to delete all backups sets that are older than the count:th last full backup. In other words, keep the last count full backups and associated incremental ets). The count must be larger than zero. A value of 1 means that only the single most recent backup chain will be kept. Note that the option –force will be needed to delete the files rather than just list them.

duplicity remove-all-but-n-full 10 –encrypt-key= 4AABBCC7  –force scp://userNameHere@cloud.example.com/backups

Restore (recover) last backup duplicity command

Now suppose you accidentally delete /home/nixcraft/ and want to restore it the way it was at the time of last backup, enter:

mkdir /home/nixcraft/

duplicity –encrypt-key= 4AABBCC7  scp://userNameHere@cloud.example.com/backups /home/nixcraft/

Restore (recover) specific file duplicity command

If you wanted to restore just the file “Documents/resume.doc” in /home/nixcraft/ as it was seven days ago into /home/nixcraft/Documents, type:

duplicity -t 7D –file-to-restore= Documents/resume.doc  –encrypt-key= 4AABBCC7  scp://userNameHere@cloud.example.com/backups /home/nixcraft/Documents

Cleaning up backups

You can delete the extraneous duplicity files. Non-duplicity files, or files in complete data sets will not be deleted. This should only be necessary after a duplicity session fails or is aborted prematurely. Note that the –force option will be needed to delete the files rather than just list them:

duplicity cleanup –force –encrypt-key= 4AABBCC7  scp://userNameHere@cloud.example.com/backups

Putting it all together

A sample shell script:

#!/bin/bash

# A simple backup script wrapper for duplicity.

# Author – nixCraft <www.cyberciti.biz> under GPL v2+

# —————————————————–

 

Define VARS ##

_gpg_key= 4AABBCC7

_target= scp://userNameHere@cloud.example.com/backups

_duplicity= /usr/bin/duplicity

_src= /home/nixcraft/

 

Unlock ssh/scp/sftp ##

source $HOME/.keychain/$HOSTNAME-sh

 

Cleanup ##

$_duplicity –force –encrypt-key= ${_gpg_key}  ${_target}

 

Rotate old backups than 60 days ##

$_duplicity remove-older-than 60D –encrypt-key= ${_gpg_key}  ${_target}

 

Backup our home sweet home i.e. /home/nixcraft/ ##

Note: full backup if older than 60 day else do incremental backup ###

$_duplicity ${_src} –encrypt-key= ${_gpg_key}  –full-if-older-than 60D ${_target}

Setup cron job as follows:

@daily /path/to/your/awesome/backup.script.sh

Recommend readings:

Man pages: ssh(1),scp(1),duplicity(1),cron(8),bash(1)

duplicity home page

 

 

]]>
http://wiki.shopingserver.com/debian-ubuntu-install-duplicity-encrypted-backup-cloud/feed/ 0
SteamOS Default Login Password For Steam Machine http://wiki.shopingserver.com/steamos-default-login-password-steam-machine/ http://wiki.shopingserver.com/steamos-default-login-password-steam-machine/#respond Sat, 06 Jan 2018 09:24:43 +0000 http://wiki.shopingserver.com/?p=18529 I

am a new Linux user and built my own Steam Machine. The system is powered by Linux-based operating system called SteamOS. What is the default default login password for SteamOS? How can I login into SteamOS?

 

SteamOS Beta is the first public release of our Linux-based operating system. The base system draws from Debian 7, code named Debian Wheezy. After installing SteamOS for the first time log onto the resulting system using the Gnome session with the following details:

Account: steam

Password: steam

Run steam, accept the EULA. The system will do rest of the setup. Logoff the steam account. Next login with the following:

Account: desktop

Password: desktop

From a terminal window, run the following command:

$ ~/post_logon.sh

This will prompt for a password – enter desktop. This script will perform the post-install customizations, then reboot. When the system reboots and comes back online you should have a functioning SteamOS install.

References

SteamOS download page.

 

 

]]>
http://wiki.shopingserver.com/steamos-default-login-password-steam-machine/feed/ 0
Linux: Keep An Eye On Your System With Glances Monitor http://wiki.shopingserver.com/linux-keep-eye-system-glances-monitor/ http://wiki.shopingserver.com/linux-keep-eye-system-glances-monitor/#respond Sat, 06 Jan 2018 08:48:08 +0000 http://wiki.shopingserver.com/?p=18485 I

s there is a tool that can provide me a maximum of information (such as cpu, disk I/O, network, nfsd, memory and more) about my Linux/Unix server in a minimum of space in a terminal?

 

There are plenty of monitoring tools on Linux or Unix-like systems that can provide information about your server:

CPU load

OS Name/Kernel version

System load

Disk and Network I/O

Process

Memory usage

Mount point and much more.

Say hello to Glances

From the project home page:

Glances is a free (LGPL) cross-platform curses-based monitoring tool which aims to present a maximum of information in a minimum of space, ideally to fit in a classical 80×24 terminal or higher to have additionnal information. Glances can adapt dynamically the displayed information depending on the terminal size. It can also work in a client/server mode for remote monitoring.

This utility is written in Python and uses the psutil library to fetch the statistical values from your server.

Installation

You can install Glances using pip command line tool. You will also find packages for Arch Linux, Fedora/CentOS/RHEL, Debian, Ubuntu (13.04+), FreeBSD, OSX and so you should be able to install it using your favorite package manager as follows:

Install Glances on CentOS/Fedora/RHEL/Scientific Linux

First, turn on Extra Packages for Enterprise Linux (or EPEL) repo on CentOS/RHEL/SL. Type the following yum command:

# yum -y install glances

 

Sample outputs:

yum install glances

Loaded plugins: product-id, protectbase, rhnplugin

This system is receiving updates from RHN Classic or RHN Satellite.

rhel-x86_64-server-6                                 | 1.5 kB     00:00

rhel-x86_64-server-optional-6                        | 1.5 kB     00:00

0 packages excluded due to repository protections

Setting up Install Process

Resolving Dependencies

–> Running transaction check

—> Package glances.noarch 0:1.7.1-1.el6 will be installed

–> Processing Dependency: python-psutil >= 0.4.1 for package: glances-1.7.1-1.el6.noarch

–> Processing Dependency: python-setuptools for package: glances-1.7.1-1.el6.noarch

–> Running transaction check

—> Package python-psutil.x86_64 0:0.6.1-1.el6 will be installed

—> Package python-setuptools.noarch 0:0.6.10-3.el6 will be installed

–> Finished Dependency Resolution

 

Dependencies Resolved

 

============================================================================

Package             Arch     Version          Repository              Size

============================================================================

Installing:

glances             noarch   1.7.1-1.el6      epel                   107 k

Installing for dependencies:

python-psutil       x86_64   0.6.1-1.el6      epel                    84 k

python-setuptools   noarch   0.6.10-3.el6     rhel-x86_64-server-6   336 k

 

Transaction Summary

============================================================================

Install       3 Package(s)

 

Total download size: 527 k

Installed size: 843 k

Is this ok [y/N]: y

Downloading Packages:

(1/3): glances-1.7.1-1.el6.noarch.rpm                | 107 kB     00:00

(2/3): python-psutil-0.6.1-1.el6.x86_64.rpm          |  84 kB     00:00

(3/3): python-setuptools-0.6.10-3.el6.noarch.rpm     | 336 kB     00:00


Total                                       1.8 MB/s | 527 kB     00:00

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : python-psutil-0.6.1-1.el6.x86_64                         1/3

Installing : python-setuptools-0.6.10-3.el6.noarch                    2/3

Installing : glances-1.7.1-1.el6.noarch                               3/3

Verifying  : python-setuptools-0.6.10-3.el6.noarch                    1/3

Verifying  : python-psutil-0.6.1-1.el6.x86_64                         2/3

Verifying  : glances-1.7.1-1.el6.noarch                               3/3

 

Installed:

glances.noarch 0:1.7.1-1.el6

 

Dependency Installed:

python-psutil.x86_64 0:0.6.1-1.el6

python-setuptools.noarch 0:0.6.10-3.el6

 

Complete!

Install Glances on Debian/Ubuntu Linux (13.04+)

Type the following command:

$ sudo apt-get install glances

 

Sample outputs:

Reading package lists… Done

Building dependency tree

Reading state information… Done

The following extra packages will be installed:

python-jinja2 python-markupsafe python-psutil

Suggested packages:

python-jinja2-doc

The following NEW packages will be installed:

glances python-jinja2 python-markupsafe python-psutil

0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.

Need to get 734 kB of archives.

After this operation, 2,429 kB of additional disk space will be used.

Do you want to continue? [Y/n]

Get:1 http://mirrors.service.networklayer.com/ubuntu/ trusty/main python-markupsafe amd64 0.18-1build2 [14.3 kB]

Get:2 http://mirrors.service.networklayer.com/ubuntu/ trusty/main python-jinja2 all 2.7.2-2 [161 kB]

Get:3 http://mirrors.service.networklayer.com/ubuntu/ trusty/main python-psutil amd64 1.2.1-1ubuntu2 [50.2 kB]

Get:4 http://mirrors.service.networklayer.com/ubuntu/ trusty/universe glances all 1.7.3-2ubuntu1 [509 kB]

Fetched 734 kB in 0s (6,667 kB/s)

Selecting previously unselected package python-markupsafe.

(Reading database … 64983 files and directories currently installed.)

Preparing to unpack …/python-markupsafe_0.18-1build2_amd64.deb …

Unpacking python-markupsafe (0.18-1build2) …

Selecting previously unselected package python-jinja2.

Preparing to unpack …/python-jinja2_2.7.2-2_all.deb …

Unpacking python-jinja2 (2.7.2-2) …

Selecting previously unselected package python-psutil.

Preparing to unpack …/python-psutil_1.2.1-1ubuntu2_amd64.deb …

Unpacking python-psutil (1.2.1-1ubuntu2) …

Selecting previously unselected package glances.

Preparing to unpack …/glances_1.7.3-2ubuntu1_all.deb …

Unpacking glances (1.7.3-2ubuntu1) …

Processing triggers for ureadahead (0.100.0-16) …

ureadahead will be reprofiled on next reboot

Processing triggers for man-db (2.6.7.1-1ubuntu1) …

Setting up python-markupsafe (0.18-1build2) …

Setting up python-jinja2 (2.7.2-2) …

Setting up python-psutil (1.2.1-1ubuntu2) …

Setting up glances (1.7.3-2ubuntu1) …

Creating system user  glances .

* Starting Glances server glances                                                                                  * Not starting glances: disabled by /etc/default/glances.

Processing triggers for ureadahead (0.100.0-16) …

Turn on glances by editing the /etc/default/glances file, enter:

# vi /etc/default/glances

 

Update it as follows to ‘true’ to have glances running at startup:

RUN= true

Save and close the file. Start glances:

# service glances start

How do I use glances?

The basic syntax is:

# glances

# glances [options]

 

Sample outputs:

Fig.01: glances in action (click to enlarge)

 

To quit just press q (Esc and Ctrl-C also work). Here is another output from Ubuntu based system:

Fig.02: Glances in action (Image credit – Glances author)

HTML5 capable browser user can view quick video demo by clicking the following link:

Sorry, your browser doesn’t support HTML5 video.

(Video 01: Glances command in action)

Fine tuning output (interactive commands)

Use the following hot keys to find tune your output:

a Sort processes automatically.

c Sort processes by CPU%.

m Sort processes by MEM%.

p Sort processes by name.

i Sort processes by I/O rate.

d Show/hide disk I/O stats.

f Show/hide file system stats.

n Show/hide network stats.

s Show/hide sensors stats.

y Show/hide hddtemp stats.

l Show/hide logs.

b Bytes or bits for network I/O.

w Delete warning logs.

x Delete warning and critical logs.

1 Global CPU or per-CPU stats.

t View network I/O as combination.

u – View cumulative network I/O.

How do I use Glances in client/server mode?

On server type the following command to bind server to the given IPv4/IPv6 address or hostname:

# glances -B @IP|host

# glances -B 75.126.153.206

# glances -B www.cyberciti.biz

 

From your desktop client such as OSX/FreeBSD/Linux based system type the following command to connect to a Glances server by IPv4/IPv6 address or hostname:

# glances -c @IP|host

# glances -c 75.126.153.206

# glances -c www.cyberciti.biz

 

You may need to pass the -P password to set a client/server password. The -s run Glances in server mode:

How do I refresh information every 5 seconds?

Type the following command:

# glances -t 5

How do I see all supported options?

This command has many more options, type the following command at shell prompt:

$ glances -h

 

Sample outputs:

Glances version 1.7.3 with PsUtil 1.2.1

Usage: glances [options]

 

Options:

-b  Display network rate in Byte per second

-B @IP|HOST Bind server to the given IPv4/IPv6 address or hostname

-c @IP|HOST Connect to a Glances server by IPv4/IPv6 address or hostname

-C FILE  Path to the configuration file

-d  Disable disk I/O module

-e  Enable sensors module

-f FILE  Set the HTML output folder or CSV file

-h  Display the help and exit

-m  Disable mount module

-n  Disable network module

-o OUTPUT Define additional output (available: HTML or CSV)

-p PORT  Define the client/server TCP port (default: 61209)

-P PASSWORD Define a client/server password

–password Define a client/server password from the prompt

-r  Disable process list

-s  Run Glances in server mode

-t SECONDS Set refresh time in seconds (default: 3 sec)

-v  Display the version and exit

-y  Enable hddtemp module

-z  Do not use the bold color attribute

-1  Start Glances in per CPU mode

See also

Glances is not the only option. You can try:

How to install and use atop – an advanced system & process monitor.

How to install and use htop – an interactive process viewer.

Linux: Find Out What Process Are Using Swap Space

Install and Use nmon Tool To Monitor Linux Systems Performance

Top 20 recommend old good Linux and Unix system monitoring tool such as top, vmstat, mpstat, ps, iostat, sar, pmap and more.

Glances project home page or try pypi Glances repo for more info.

Linux: Monitor Hard Disks Temperature With hddtemp.

Man page: glances(1)

 

 

]]>
http://wiki.shopingserver.com/linux-keep-eye-system-glances-monitor/feed/ 0