Thursday, August 2, 2018

How to use the gpg command to encrypt Linux files

https://www.networkworld.com/article/3293052/linux/encypting-your-files-with-gpg.html

Encryption commands such as gpg can be used to secure your most sensitive files on Linux systems.

Encypting your files with gpg
Amanda Slater (CC BY-SA 2.0)
There are many reasons to encrypt files — even on a system that is well maintained and comparatively secure. The files may highly sensitive, contain personal information that you don't want to share with anyone, or be backed up to some variety of online storage where you'd prefer it be extra secure.
Fortunately, commands for reliably encrypting files on Linux systems are easy to come by and quite versatile. One of the most popular is gpg.

gpg vs pgp and OpenPGP

Used both to encrypt files in place and prepare them to be sent securely over the Internet, gpg is related to, but not the same as, pgp and OpenPGP. While gpg is based on the OpenPGP standards established by the IETF, it is — unlike pgp — open source. Here's the rundown:
  • OpenPGP is the IETF-approved standard that defines encryption technology that uses processes that are interoperable with PGP.
  • pgp is Symantec's proprietary encryption solution.
  • gpg adheres to the OpenPGP standard and provides an interface that allows users to easily encrypt their files.

Using gpg for symmetric encryption

Symmetric encryption means that you use the same key to both encrypt and decrypt a file. To encrypt a file with minimal effort, you could use a command like this:
$ gpg2 --symmetric myfile
This command will leave you with two files — myfile and myfile.gpg. Once you verify that the encrypted version of your original file has been created, you can use the shred command to securely remove the original file in a way that prevents it from being scraped off the disk with some disk recovery tool. During the encryption process, this command will also open up a tool on your desktop to prompt you twice to enter your passphrase. So, you have to be working on the desktop.
To do this kind of thing when you're not working on the console, you can avoid having gpg trying to open up a GUI tool to prompt for your passphrase by supplying it on the command. In this case, you might use a command like this:
$ gpg --pinentry-mode loopback --passphrase 88bottlesOfBeer --symmetric myfile
$ ls -l myfile.*
-rw-r--r-- 1 shs shs 48721 Jul 30 19:52 myfile.gpg
NOTE: It's bad practice to store your passphrase in clear text -- even in your command history file, so be careful if you do this.

Using public and private keys

To use gpg for creating files that you want to share with other people, it's generally best to use private/public keys. To share a file with a particular person, you encrypt it using their public key. In that case, that person is (presumably) the only one who can decrypt it. If you encrypt a file with your own public key, you’re the only one who can decrypt it.
To generate your public and private key set with gpg, you would use a command like this:
$ gpg --gen-key
Note that this command also requires that you be working on the console (GUI), not through an ssh session. The command is going to require that you produce some activity while your keys are bring generated — such typing or as moving your mouse cursor around the screen — to provide random data to the encryption process. It will also ask you to supply some information, such as your full name and the email address to be used for the key.
To encrypt a file for a particular recipient, you need to use a command that includes the --recipient argument to specify the recipient's public key.
$ gpg --encrypt --recipient myfriend@gmail.com instructions
$ ls -l instructions.*
-rw-rw-r-- 1 shs shs 51665 Jul 30 19:34 instructions.gpg
It's interesting to note that while the private and public keys are linked (generated in a single operation), either key could play either role.
  • If you encrypt with the public key, you could decrypt with the private key
  • If you encrypt with the private key, you could decrypt with a public key
Convention dictates, however, that private keys are kept private.
We also haven't looked at how public keys are used for authenticating senders.

Other command options

The gpg command offers many other options, as well. For example, if you prefer to use other than the default AES-128 encryption algorithm, you can specify the one you want to use with a command like this:
$ gpg --cipher-algo AES256 --symmetric myfile
You can list your keys with this command:
$ gpg --list-keys

Wrap-up

While gpg commands can become quite complicated, the things you're likely to do routinely can be accomplished without a lot of effort.
Join the Network World communities on Facebook and LinkedIn to comment on topics that are top of mind.

Wednesday, August 1, 2018

ABC of using Traceroute command in Linux

https://linuxtechlab.com/using-traceroute-command-in-linux

Traceroute command is well known networking utility using which we can determine the number of hops between source & destination of a network packet. Not only does it show the number of hops, we will also get the information regarding the path/servers it goes through.
Traceroute command is well known networking utility using which we can determine the number of hops between source & destination of a network packet.Usually the traceroute command in Linux is used to determine the data loss occurring in the network, as each hop shows the network address of the router or server it passes, we can know at which server or router our packet was lost.
Recommended Read : Monitoring network bandwidth with iftop command
Also Read : Let’s discuss some examples of SED command
In this tutorial, we are going to discuss how we can install traceroute command in Linux & also how to use it to troubleshoot the network.

Install Traceroute command in Linux

Traceroute command comes pre-installed on many Linux distributions but if that’s not the case with you, you can install it using one of the following commands,
CentOS/RHEL/Oracle Linux/Amazon Linux
# yum install traceroute
Ubuntu/Debian/Mint
# apt-get install traceroute
Fedora
# dnf install traceroute
If using sudo user, than add sudo before the installation command. Now let’s discuss the syntax for using traceroute command in Linux,
Syntax
# traceroute [option] destination
Now let’s discuss some examples for using traceroute command in Linux.

Examples of traceroute command in Linux

1- Check route for a server
To simply get the route taken by a network packet to get to a certain server or website (for example google), run the following command from the terminal,
$ traceroute google.com
We can run the traceroute against an IP address of a server or website,
$ traceroute 8.8.8.8
As output we will get the following result,
Traceroute command in Linux
Now output shows the following info,
– First line after the command shows the destination IP address (blacked out in the screenshot),
– Next line after that & all the rest lines shows the hops, their IP address, response time etc.
By default, traceroute command in linux sends 3 packets for each hop, hence we get three response time on each line.
– Sometimes we might get a ‘*’ in place of response time, that shows that we were unable to get a response for that request.
Both examples mentioned above uses IPV4, but to send a query for IPv6 we can use following example as reference,
$ traceroute -6 ipv6.google.com
This example itself is sufficient enough for network troubleshooting but we can also change the default values of traceroute command to satisfy our requirements.
2- Configure TTL for traceroute
By default the TTL value for traceroute command is 1, but we can configure it to some other value using option ‘f’, for example
$ traceroute -f 5 google.com
3- Configure the response wait time
The response wait time can also be changed to a value other than the default value using the option ‘w’,
$ traceroute -w 0.5 google.com
4- Configure number of queries
Per hop, traceroute sends 3 queries/packets & provide 3 round trip time. Now let’s suppose we want to send 4 packets per hop, we can do it using option ‘q’,
$ traceroute -q 4 google.com
5- Disable IP, Hostname mapping
Option ‘n’ can be used with traceroute command to disable IP address & hostname mapping,
$ traceroute -n google.com
6- Configure network interface for traceroute
If using multiple network interfaces on Linux system, we can also configure traceroute to use only a particular interface using option ‘i’,
$ traceroute -i enp2s0 google.com
We now end this tutorial on using traceroute command in Linux, we have only discussed some of the commonly used options of traceroute. There are many more options that can be used with traceroute command, refer to MAN pages for all the available options for traceroute command in Linux.

If you have found this article to be useful, please share it among your friends/colleagues/followers. THANKS !!!

Different Ways to Access Google Drive on Linux Desktop

https://www.linuxtechi.com/different-ways-access-google-drive-linux-desktop

Google Drive is a cloud-based file storage that allows you store your files on Google Servers, share files with other users and also synchronize the files among various devices including your computer, mobile phone, tablets etc. To access Google Drive you only need to have Gmail account and even offers 15GB of free storage space.
Different-Ways-Access-Google-Drive-Linux-Desktop
Launched in 2012, Google Drive can be easily accessed in Windows system, Android and iOS but Google is yet to announce an official client for Linux desktops to access your files in Google Drive. But there may tools available in Linux that allows you to easily access Google Drive. In this article, we are going to look for different ways to access Google Drive on Linux Desktop.

Insync

When it comes to providing complete access to Google Drive from Linux, Insync is one of the best clients available to come with a lot of features and provides you options to get anything you need from Google Drive. It also supports multiple Google Drive accounts, notification features etc.
It is supported in many of the popular Linux distributions and the installation process is also pretty straightforward and simple. It also comes with an attractive GUI to enable easy access of Google Drive and its features. A command line interface is also supported.
But the main problem it is available for free only for 15 days and you need to pay for using the software after 15 days. And it will cost around $29 for a single user account and separate packages available for multiple account usage. And if you willing to pay some money, we can definitely say that Insync is the best Google drive client available for Linux Desktop.

Access Google Drive from Ubuntu Desktop

Unlike Windows and MacOS, accessing Google Drive from a Ubuntu desktop is slightly different. Let’s take a look at how to access the Google Drive from your Ubuntu Desktop
  1. In your Ubuntu Desktop, go to Settings –> Online Accounts
  2. In Online Accounts you can see all your various accounts listed. Click the “Add” button to add your Google account
  3. Now select Google from the list and provide your user credentials for your Google Account
  4. Once you’ve provided your username and password, it will ask you ALLOW for permissions, just click “ALLOW“
  5. In the next window, you can see option to enable/disable various Google features including Mail, Photos, Files, Documents, Calendar, Contacts, Chat etc.
  6. Click ON to enable the required functions
  7. Your Google Drive is ready for use now
  8. Mount your Google Drive by opening the Files Window and double-click on your Google account to mount it in your system
  9. You can add, remove any files and folder to your local drive to your Google Drive or vice versa.
  10. You can also see a separate drive icon appearing on your desktop for your Google Drive

OverGrive

OverGrive is another interesting Linux desktop client that lets you access most of the features of Google Drive and the only exceptions that there is no symlink support provided. The GUI is pretty much simple and easy to navigate and the installation is also straightforward and simple. OverGrive is supported in all major Linux distributions and is also available in various languages as well. But OverGrive is not available for free, but when you compare the price with Insync, you can get OverGrive for less than $5.

Rclone

Rclone is another Google Drive client but a command line program that allows you to manage your files in your Google drive and sync files between various other cloud storage devices like Amazon S3, Dropbox, OneDrive etc. The installation is very simple and there is a descriptive installation guide and usage manual available in their official website. The main aspect about Rclone is that is available completely for free. And if you are fan of command line interfaces, then you will certainly like this Google Drive client.

Conclusion

It is certainly disappointing why Google has not come up with an official Google Drive client for Linux even after it was launched for Windows and iOS about 6 years before. But until they launch one, if you are looking to use Google Drive from your Linux desktop, then you certainly need to use any one of these clients to access Google Drive. Please post your comments and suggestions in the comments section and we’ll be happy to revert back at the earliest.