Thursday, July 7, 2022

Secure remote backups with Rsync and SSH

Many Linux users know rsync as a file transfer utility. Rsync is an efficient tool for automating remote backups of Linux, Windows, and even Mac OS X systems.

Prerequisites:
To perform secure remote backups, rsync and SSH must be installed installed on both local and target remote machine. Rsync can use SSH as a secure transport agent.
Make sure rsync is installed by opening a terminal session and typing rsync --version on each machine. You should see a message like rsync version 2.X.X protocol version X.
To ensure that sshd is running on a remote machine, enter a terminal session and type ssh <user>@<remote IP address>.

When all the prerequisites are met, select the folder that needs to be sync from local to the remote host and create a folder in the destination to store the backed up data.

rsync -avz -e ssh /some/small/directory/ remote_user@remotehost.com:/backup/destination/directory/

Please note that the trailing slash in the source directory causes rsync to copy only the contents of the source directory. Omitting the trailing slash causes rsync to copy both the directory name and its contents to the destination.

Tuesday, March 15, 2022

Dell Inspiron 14 5000 Series with Ubuntu 20.04 does not turn on

Remove kernel

sharma@Sharma-LAP:~/Downloads/new-kernal$ dpkg -l | grep linux-image
ii  linux-image-5.13.0-30-generic              5.13.0-30.33~20.04.1                amd64        Signed kernel image generic
ii  linux-image-generic-hwe-20.04              5.13.0.30.33~20.04.17               amd64        Generic Linux kernel image
ii  linux-image-unsigned-5.16.0-051600-generic 5.16.0-051600.202201092355          amd64        Linux kernel image for version 5.16.0 on 64 bit x86 SMP
sharma@Sharma-LAP:~/Downloads/new-kernal$
sharma@Sharma-LAP:~/Downloads/new-kernal$
sharma@Sharma-LAP:~/Downloads/new-kernal$ dpkg -l | grep linux-head
ii  linux-headers-5.13.0-30-generic            5.13.0-30.33~20.04.1                amd64        Linux kernel headers for version 5.13.0 on 64 bit x86 SMP
ii  linux-headers-5.16.0-051600                5.16.0-051600.202201092355          all          Header files related to Linux kernel version 5.16.0
ii  linux-headers-5.16.0-051600-generic        5.16.0-051600.202201092355          amd64        Linux kernel headers for version 5.16.0 on 64 bit x86 SMP
ii  linux-headers-generic-hwe-20.04            5.13.0.30.33~20.04.17               amd64        Generic Linux kernel headers
sharma@Sharma-LAP:~/Downloads/new-kernal$
sharma@Sharma-LAP:~/Downloads/new-kernal$
sharma@Sharma-LAP:~/Downloads/new-kernal$
sharma@Sharma-LAP:~/Downloads/new-kernal$ sudo apt-get purge linux-image-unsigned-5.16.0-051600-generic






The following steps will remove a given kernel along with its drivers drivers, and lets the package manager know that you don’t want it again if you do an update. You should remove the specific broken kernel and it’s headers, don’t remove the super package linux-generic this is the package that Ubuntu uses to upgrade the kernel and headers when they become available. If you remove it you wont get kernel updates automatically and will have to specifically run apt-get to get them.

    Open Terminal (if it’s not already open)
    List the available kernels:

    dpkg -l | grep linux-image

    Remove the kernel(s) you don’t want:

    sudo apt-get purge linux-image-5.8.0-53-generic

    Remove the headers as well:

    sudo apt-get purge linux-headers-5.8.0-53-generic

    Reboot





wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.11/amd64/linux-headers-5.16.11-051611-generic_5.16.11-051611.202202230823_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.11/amd64/linux-headers-5.16.11-051611_5.16.11-051611.202202230823_all.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.11/amd64/linux-image-unsigned-5.16.11-051611-generic_5.16.11-051611.202202230823_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.11/amd64/linux-modules-5.16.11-051611-generic_5.16.11-051611.202202230823_amd64.deb



cd ~/Downloads

wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16/amd64/linux-headers-5.16.0-051600_5.16.0-051600.202201092355_all.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16/amd64/linux-headers-5.16.0-051600-generic_5.16.0-051600.202201092355_amd64.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16/amd64/linux-image-unsigned-5.16.0-051600-generic_5.16.0-051600.202201092355_amd64.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16/amd64/linux-modules-5.16.0-051600-generic_5.16.0-051600.202201092355_amd64.deb

sudo dpkg -i *.deb
sudo apt -f install






wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.13/amd64/linux-headers-5.16.13-051613_5.16.13-051613.202203082004_all.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.13/amd64/linux-headers-5.16.13-051613-generic_5.16.13-051613.202203082004_amd64.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.13/amd64/linux-image-unsigned-5.16.13-051613-generic_5.16.13-051613.202203082004_amd64.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.13/amd64/linux-modules-5.16.13-051613-generic_5.16.13-051613.202203082004_amd64.deb
                                







mkdir tmp
cd tmp
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.11/amd64/linux-headers-5.16.11-051611-generic_5.16.11-051611.202202230823_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.11/amd64/linux-headers-5.16.11-051611_5.16.11-051611.202202230823_all.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.11/amd64/linux-image-unsigned-5.16.11-051611-generic_5.16.11-051611.202202230823_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.11/amd64/linux-modules-5.16.11-051611-generic_5.16.11-051611.202202230823_amd64.deb


sudo dpkg -i *.deb

You'll get an error while installing ..._all.deb since you've got outdated libc6 and libssl3 versions. You'll notice that sudo apt install libssl3 doesn't work, let's fix that.

    Add the Ubuntu 22.04 repo:

sudo add-apt-repository "deb http://ca.archive.ubuntu.com/ubuntu jammy main"

    Now if you try to install libssl3 it'll tell you to run the following command instead:

sudo apt --fix-broken install

    Now I think you're good to go, but I also ran the dpkg command once more to make sure:

sudo dpkg -i *.deb




https://wiki.ubuntu.com/UEFI/SecureBoot/DKMS







Option 1. Install Linux Kernel 5.16 with PPA
Import TuxInvader PPA

The first option to install the Linux 5.16 kernels is to install the ppa:tuxinvader/lts-mainline by TuxInvader. This has some of the most up-to-date 5.16, and the previous 5.15 kernel builds and is often updated regularly.

The drawback is this is an untrusted PPA and not an official release by the Pop!_OS or Ubuntu official teams, but given the history of the PPA, it is safe as any other reputable PPA. You should not be installing this on a sensitive or production-type system anyway.

First, install the LTS Mainline Tuxinvader PPA:

sudo add-apt-repository ppa:tuxinvader/lts-mainline -y

Once installed, update your repository list.

sudo apt update

Next, proceed to the installation of the Linux Kernel. Make sure at this point any sensitive documents are backed up just in case of anything going wrong.
Install Linux Kernel 5.16 from Tux PPA

Next, install the 5.16 generic Linux kernel drivers by executing the following command.

sudo apt-get install linux-generic-5.16 -y

Once complete, you will need to reboot your system for the new kernel to be fully activated.

reboot

Once logged back into your system, run the following command to confirm the new kernel version is running.

sudo uname -r

Example output:

5.16.0-051600-generic

Option 2. Install Linux Kern




Remove a PPA from the source list in the terminal

Not my preferred method at all. I don’t recommend it as well but it gets the job done.

You can remove the PPA from the sources list where these PPAs are stored. PPA repositories are store in the form of PPA_Name.list.

Use the following command to see all the PPAs added in your system:

ls /etc/apt/sources.list.d

Look for your desire PPA here and then remove the .list file associated with the PPA using the following command:

sudo rm -i /etc/apt/sources.list.d/PPA_Name.list

The -i option with rm command asks before removing a file. Consider this a safety check.
Method 4. Remove a PPA by using ppa-purge in the terminal

You might have noticed that in all the above three methods we only talked about deleting or removing a PPA. What about the applications installed using these PPAs? Will they be removed as a result of removing the PPA? The answer is NO.

So this is when PPA Purge comes in picture. It not only disables the PPA but also uninstalls all the programs installed by the PPA or revert them to original version provided by your distribution.

Install ppa-purge by using the following command:

sudo apt-get install ppa-purge

Now use it in following manner to purge the PPA:

sudo ppa-purge ppa-url

The URL of the PPA can be found in the Software Sources list.

I hope you’ll find at least one good method to delete or remove a PPA and uninstall the corresponding applications. Cheers :)



Thursday, January 27, 2022

What's Best for Remote Workers: VDI or VPN?

VPN serves to create a secure tunnel between an endpoint device and the company network allowing secure remote access to company network from an internet location. When granting VPN access, administrators need to carefully allow access permissions to required systems, allowing users only to access designated systems.

VDI (Virtual Desktop Infrastructure) generally transmit virtualized hosted desktop environments and/or business applications. VDI is device-agnostic and it doesn’t rely on the end-user hardware. If required, own dedicated Windows-based system can be provided to each user so that they can be customized. Each machine can be configurued to work independently of the others.

With VPN, the processing is done on the client machine whereas VDI processing is  done at the server side. Further VDI can be configured to restrict data from leaving the corporate network. However with VPN, data can still be moved to client devices unless extra  measures have not been configured to prevent such attempts.

Both VPN and VDI are used for gaining secure remote access. Even though VPN is  more suitable for smaller businesses as it is cost-effective, easy to implement, and simple to use, Companies with the increased number of work from home users consider  VDI as more effective in enabling WFH arrangements.

Any vulnerabilities on using the windows 7?

MS  Windows 7 reached end of life by January  14, 2020. However Windows 7 Extended Security Updates (ESU) provides security updates for critical and important issues as defined by Microsoft Security Response Center (MSRC) for a maximum of three years from Jan 14, 2020. ESU is available only for Windows 7 Professional and Windows 7 Enterprise. Organizations can purchase ESU at any time during the three years that the offer is available (2020, 2021, and 2022).

If you have not purchased ESU, any Windows 7 PCs (Professional or Enterprise) will not receive security updates. Therefore with all these older version of operating systems unpatched security holes/vulnerabilities will be gradually accumulated within your IT infrastructure. It increases the overall security risks due to unpatched vulnerabilities leaving the environment more susceptible for security threats.

I recommend upgrading to Windows 10 or 11 whenever possible.

Reference:

[1] https://docs.microsoft.com/en-us/troubleshoot/windows-client/windows-7-eos-faq/windows-7-extended-security-updates-faq

Monday, January 3, 2022

Does telnet client represent a security?

I always advice to disable telnet unless telnet use is absolutely necessary. Telnet sends authentication details (username and password) in clear text, allowing packet sniffers to read credentials. Further this can be used as a callout mechanism by malware.

Disabling the Telnet service will prevent logging into the server using valid account credentials.

Having a telnet client isn't a critical/high risk threat in itself, if you're using it within your local network. The less tools are left to the user, the less mistakes he can do with them.

The main usage of telnet client (Without enabling the server service) is to test network exchanges at low level. However this will be of no use for the general user and will only be required by the relevant administrators who wants to troubleshoot connectivity.

Simply the last assumption behind disabling the telnet client is that a user who really needs it will certainly be able to enable it.


Wednesday, November 24, 2021

Should you require to extract the product key from pre-installed MS Windows 10

There is no need to know the product key, since the machine has a digital entitlement. 

 If you need to reinstall MS Windows due to a reason out of many, you may think that you require the product key of the preinstalled with Windows 10. Really you don't require the product key. what happened is the hardware (your PC) will get a digital entitlement, where a unique signature of the computer will be stored on Microsoft Activation Servers.

Anytime you need to reinstall Windows 10 on that machine, just proceed to reinstall Windows 10. It will automatically reactivate. 

If you are prompted to enter a product key, click 'I don't have a key' and 'Do this later'

If you want to really find the product key:

  1. Open the command line as the administrator (Run As Administrator)
  2. Type the command:
    • wmic path SoftwareLicensingService get OA3xOriginalProductKey
  3. Hit enter, the product key will be revealed
  4. Copy the product key to a text file.

Monday, November 1, 2021

SSL/TLS Cipher Suites and Perfect Forward Secrecy

An SSL cipher, or an SSL cipher suite, is a set of algorithms or a set of instructions/steps that helps to establish a secure connection between two entities — usually the client (a user’s browser) and the web server they’re connecting to (your website).

Creating a secure, encrypted connection via the SSL/TLS protocol is a fairly complex process that has many layers to it. In technical terms, it’s regarded as an “SSL/TLS handshake.” This includes key exchange, identity verification, data encryption, etc.

To negotiate a secure communication, the client and the server need to come on terms with four crucial elements:

  1. Key exchange algorithm: RSA (Rivest–Shamir–Adleman), DH (Diffie-Hellman), ECDH (Elliptic-curve Diffie-Hellman), and ECDHE (Elliptic-curve Diffie-Hellman Ephemeral) are some of the most widely used key exchange algorithms.
  2. Bulk encryption algorithm: Encrypt messages exchanged between clients and servers. Ex. AES.
  3. Data encryption algorithm
  4. Hash function: Generate message hashes and signatures to ensure the integrity of a message

A cipher suite is a set of cryptographic algorithms that describes the above four elements.

This is an example of a cipher suite: 

TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384

  • TLS : Protocol
  • ECDHE : The first part is the key exchange algorithm.
  • RSA: It uses a key signed with an RSA certificate authority which is supported by most internal certificate authorities
  • AES_256_GCM: The third section is the type of encryption algorithm used.
  • SHA384: The fourth component is the type of hashing algorithm used.
TLS 1.2, the most extensively used version of TLS in the world, has 37 ciphers in total. However, not all of them are safe enough to use. Here’s a list of some of the TLS 1.2 ciphers:
  • TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
  • TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
  • TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
  • TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  • TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
  • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
  • TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
  • TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
  • TLS_DHE_RSA_WITH_AES_128_CBC_SHA
  • TLS_DHE_RSA_WITH_AES_256_CBC_SHA
  • TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
  • TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
  • TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
  • TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305
  • TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
  • TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305

Perfect Forward Secrecy for TLS

Perfect Forward Secrecy (PFS) is a concept in Transport Layer Security (TLS) that makes sure that even if attackers manage to gain access to the private key of a certificate, they are not able to decrypt communication from the past (or communication in the future, without using active man in the middle attacks). For example, if the latest key is compromised, it exposes only a small portion of the user's sensitive data.

Example of Perfect Forward Secrecy cipher suites using ephemeral key agreement with  elliptic curve Diffie-Hellman key exchange:
TLS_ECDHE_RSA_WITH_AES128_GCM_SHA256
TLS_ECDHE_RSA_WITH_AES256_GCM_SHA384
TLS_ECDHE_RSA_WITH_AES256_CBC_SHA384

Enabling perfect forward secrecy on your server: If you check the security details of a site and see that it is using "ECDHE" or "DHE" then the server is already using forward secrecy. Any key exchange that uses ephemeral keys provides forward secrecy.

Downsides of perfect forward secrecy: While they generally don't outweigh the benefits, like anything else, there are drawbacks to this type of security. To begin with, it usually requires greater processing power from a server since every transaction requires the generation of a unique encryption key. Ephemeral Elliptic Curve Diffie-Hellman is believed to be the faster of the two, but even it adds up to 20 percent greater SSL/TLS processing requirements to a server.

If you would like to test your implementation of SSL/TLS, following websites could be used:

https://www.ssllabs.com/ssltest

https://gf.dev/tls-scanner

https://www.digicert.com/help/

https://www.sslshopper.com/ssl-checker.html