megacolorboy

Abdush Shakoor's Weblog

Writings, experiments & ideas.

Install Cisco Anyconnect Client on Fedora Linux

Cisco Anyconnect Client is a SSL VPN Client with VPN functionalites that enables an organization to secure its endpoints. Although, I use it a lot at office, I have only used it on Windows 10 so far.

One day, when I was on my vacation, I had to connect to a server remotely but this time, I tried doing it via Linux and it worked well!

Download Cisco AnyConnect Client for Linux

Fortunately, the client is available for Windows, macOS and Linux. You can go to the Downloads page and download the tarball archive for Linux.

After downloading, you can extract the tarball file:

tar -xvf anyconnect-linux64-4.10.00093-predeploy-k9.tar.gz

Install Cisco AnyConnect Client for Linux

Now that the file has been extracted, you can navigate to the vpn directory in anyconnect-linux64-* directory:

cd anyconnect-linux64-*/vpn/

Execute the vpn_install.sh script:

sudo ./vpn_install.sh

Follow the instruction steps and you're ready to use it.

Connect to VPN via Terminal

The GUI version was crashing on both KDE and GNOME desktop environments. Whereas, it was a smooth experience when connecting via the Terminal.

For easy access, you can create an alias in your .bashrc file:

alias anyconnectvpn="/opt/cisco/anyconnect/bin/vpn"

Save and restart your terminal for the changes to take effect.

After that, you can connect to VPN like this:

anyconnectvpn -s connect <IP_ADDRESS>

Once executed, you'll be prompted to enter your credentials and if all goes fine, you should be connected.

Disconnect VPN via the Terminal

You can execute the following command to disconnect:

anyconnectvpn -s disconnect <IP_ADDRESS>

Configuring your VPN connection

Sometimes, it can be tedious to write these commands all the time especially when you're in a rush, this can really get in your way.

To solve that, you can easily store your credentials in a file like .my_vpn_creds in your home directory:

y
<username>
<password>

Save the file and create another file named my_vpn_connect.sh:

#!/bin/bash

VPN_SERVER="<IP_ADDRESS>"

echo "Connecting to VPN.."
/opt/cisco/anyconnect/bin/vpn -s  < ~/.my_vpn_creds connect ${VPN_SERVER}

Save the file and make the file executable:

sudo chmod +x my_vpn_connect.sh

Now, you'll be connected to the VPN automatically by just executing this script:

./my_vpn_connect.sh

This saved me a lot of time and I hope it does the same for you as well! 🤗

Hope you found this article useful!

Setup a virtual environment for Python development

virtualenv is a tool used that allows you to install and isolate Python packages that are specific to your project rather than installing them globally on your system, which might, at some point, break other tools or services in your system.

In this simple guide, I'll show you how to install and create your own Python virtual environment for development.

Before you begin, please make sure that you have installed Python 3 or greater on your system.

Install virtualenv

Using the pip tool, you can execute the following command:

sudo pip install virtualenvwrapper

Then you need to add the following lines to your .bashrc startup file (found in the home directory).

These lines determine where your virtual environments should live, the location of the script installed and the location of the development project directories:

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS=' -p /usr/bin/python3 '
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

Next, restart the startup file:

source .bashrc

Once done, it'l execute a bunch of scripts for a few minutes and once the installation is successful, you can start using the mkvirtualenv command to create your virtual environment.

Creating a virtual environment

Really, it's quite trivial to create a virtual environment like this:

mkvirtualenv my_virtual_environment

Once done, you'll notice that your terminal looks something like this:

(my_virtual_environment) user@desktop:~$

This indicates that you are inside the virtual environment and can begin installing your Python packages and begin developing your application.

Using the virtual environment

There are a few commands that I'd like to share (and you should also know) while working with a virtual environment:

  • deactivate — get out of the current virtual environment
  • workon — list available virtual environments on the system
  • workon name_of_environment — activate the specified virtual environment
  • rmvirtualenv name_of_environment — remove the specified virtual environment

Conclusion

If you are a Python developer or write code in Python, then virtual environments are super handy and disposable especially while testing and working on different projects.

Unless, your project is package-dependant, you don't really need to isolate your development environment.

Hope you found this article useful!

Install TeamViewer on Fedora Linux 36/37

If you are using Fedora Linux or any other Linux distribution and want a short guide on how to install TeamViewer on your workstation, then this article is for you.

Usually, I use it access remote servers or my computer at work but I myself never did it on a Linux workstation. It worked out for me, so it should work for you too!

1. Download TeamViewer RPM Package

You can find the latest release on TeamViewer's official site.

Make sure that you have install wget on your system to easily download it via the Terminal:

wget https://download.teamviewer.com/download/linux/teamviewer.x86_64.rpm

2. Download minizip module

During installation, it failed for me as I was missing a certain libminizip.so module. So, I looked up online and found the module and downloaded it on my workstation:

wget https://rpmfind.net/linux/fedora/linux/updates/36/Everything/x86_64/Packages/m/minizip-compat-1.2.11-33.fc36.x86_64.rpm

Once the download is complete, you can install it:

rpm -i minizip-compat-1.2.11-33.fc36.x86_64.rpm

3. Install TeamViewer

Now, the final step is to install the RPM package for TeamViewer:

rpm -i teamviewer_15.37.3.x86_64.rpm

Hope you found this short guide useful!

Connect to a Remote Windows machine from a Linux machine

Last week, my Windows machine was down and I was struggling to connect to a remote server as I'm using Fedora Linux at home.

I tried installing and using GNOME Connections but it crashed and didn't work well for me. I found another tool named rdesktop which was stable and worked well for my case.

Installing it is as easy as typing the following command using the dnf package manager:

sudo dnf install rdesktop

Now, you can connect to your remote desktop machine using the following command:

rdesktop -d <domain> -u <username> -p - <ipaddress>

Upon execution of this command, you'll be prompted to enter the password and after that, you're all good to go!

Hope you found this tip useful!

Exploring Europe

Sharing about my experiences and the places that I explored in my short three-day trip to Europe.

Trying out the Redragon K552 Kumara RGB Mechanical Keyboard

My experiences using a mechanical keyboard for the first time.

Redragon K552 Kumara RGB Keyboard

Yes, I finally did it and bought myself a mechanical keyboard after tirelessly scrolling through Amazon and YouTube for a good keyboard that doesn't hurt my pocket in the long run.

What does it feel like?

Got it delivered yesterday and as I unboxed it, I noticed that the build quality is strong and it's quite a heavy keyboard that has around 18 RGB modes to spice things up a bit.

I got the one with the Outemu Red Switches (More like a Cherry MX Red clones) and since it's a linear switch, the typing experience is buttery smooth and not at all noisy. This should be good for typing in office environments or gamers who like to be fast while playing their favorite games.

Currently, I have one issue with it i.e. that keyboard is a bit high and it kind of tires my wrists after typing for longer sessions but I guess, it can be fixed with a wrist rest (Maybe, a nice wooden one 👀).

On my first try, the keys seemed a bit fast for me as I'm not really used to typing on linear switches, let alone, on a mechanical keyboard. But as of writing this article, I got my speed back up and I have been able to achieve around 75-80WPM.

Conclusion

Apart from that, I'm quite happy about this purchase and would definitely hope that it lasts longer until I get another mechanical keyboard.

If you are looking to buy this keyboard, I'd recommend you to give a shot and see it for yourself because I feel that every programmer deserves to type on a good keyboard.

Stay tuned for more content.

Learning C# 10 and .NET Core 6

Getting back into the old roots again.

To those who haven't been following me a lot, I used to build games on Unity 3D and build desktop applications on .NET and C# during my university days.

Ever since I discovered PHP and Laravel, I never went back to .NET and now after taking a look at the Fortune benchmarks for .NET Core 6 vs Laravel, I decided to take some time out to learn it again.

I started two weeks ago and the learning curve seemed quite familiar due to previous development experiences. I don't know if it's me but I felt like Laravel might have borrowed a few concepts from .NET Core Framework but hey, everyone needs some sort of inspiration, right?

Unlike .NET, Laravel is usually and still is a "batteries included" type of framework and that helps you get the job done. However, from what I have researched, applications built on .NET seems to be more performant than applications built on Laravel.

So, what's the current progress?

Well, I haven't touched the ASP.MVC part yet as I'm geting myself familiar with the coding conventions, static typing (yes, it does take sometime to get used to) by writing some test console-based applications and solving Project Euler problems.

Hopefully, I'll be able to share about what I have learnt using the framework on this blog by either building new applications or rewriting some of my Laravel projects.

Stay tuned for more!

Temporarily disable IPV6 protocol on Ubuntu

Few days ago, I resolved an issue that I faced on an Ubuntu server that was related to SMTP not working, as a result, the server was always throwing a 504 Gateway Timeout error.

During troubleshooting, I found out that telnet smtp.office365.com 587 was not giving any response and thought that the port was blocked on the client's network but no, it wasn't.

I did a little digging and learnt that it could be due to the fact that SMTP traffic over IPV6 might be blocked on the client's network.

So, I tried executing the following commands to disable IPV6 temporarily:

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

And voila, the mails were going and SMTP traffic was working over IPV4.

If you want to enable it again, try the following:

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0

Hope you found this tip useful!