Skip to content

Instantly share code, notes, and snippets.

View SomajitDey's full-sized avatar

Somajit SomajitDey

View GitHub Profile
@SomajitDey
SomajitDey / WSLg.md
Last active March 25, 2024 16:25 — forked from 4wk-/README.md
Clean uninstall then reinstall of WSL on Windows 10, with systemD support

Uninstall then reinstall WSL on Windows 10 (clean way)

A - Uninstall wsl and related stuff

  1. In powershell (as admin)
# list all installed distros
wsl -l -v

# destroy distros
wsl --unregister Ubuntu
@SomajitDey
SomajitDey / WSL2-Windows_port-forward.md
Last active April 18, 2024 14:30
How to forward WSL2 port to Windows port and vice versa
@SomajitDey
SomajitDey / anydesk-enable-remote-access.md
Created April 2, 2023 13:56 — forked from imami/anydesk-enable-remote-access.md
AnyDesk - How Enable Remote Access from ubuntu/debian terminal

###AnyDesk - How Enable Remote Access from ubuntu/debian terminal.

Note:

Here are the commands might be usefull in this purpose:

  • anydesk --get-status : To get current status of anydesk, which might be offlien,online or nothing.
  • anydesk --get-id : To get the ID that your system can be accessed by.
  • anydesk --service : To start anydesk service if not already running (for Linux).
  • anydesk --restart-service : To restart anydesk service
  • anydesk --stop-service : To stop anydesk service
@SomajitDey
SomajitDey / getopt.bash
Last active December 26, 2022 07:40
Parse GNU style long options (--opt optarg | --opt=optarg) as well as short Unix options (-ooptarg | -o optarg). Source: https://stackoverflow.com/a/28466267.
die() { echo "$*" >&2; exit 2; } # complain to STDERR and exit with error
needs_arg() { if [ -z "$OPTARG" ]; then die "No arg for --$OPT option"; fi; }
while getopts ab:c:-: OPT; do
# support long options: https://stackoverflow.com/a/28466267/519360
if [ "$OPT" = "-" ]; then # long option: reformulate OPT and OPTARG
OPT="${OPTARG%%=*}" # extract long option name
OPTARG="${OPTARG#$OPT}" # extract long option argument (may be empty)
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
fi
@SomajitDey
SomajitDey / Makefile
Last active December 25, 2022 23:21
Sample Makefile for a Modern Fortran project
# Disable all of make's built-in rules (similar to Fortran's implicit none)
MAKEFLAGS += --no-builtin-rules --no-builtin-variables
# Fortran Compiler
FC := gfortran
# The following must have non-empty value if OpenMP is required
OMP :=
# The following must have non-empty value if Debugging compiler options are required
@SomajitDey
SomajitDey / GitHub_Workflow_CI_Build.md
Last active April 11, 2024 05:19
How to setup Continuous Integration with GitHub Actions
  • Give your Personal Access Token (PAT) access to workflow.
  • Put the accompanying build.yml inside .github/workflows path inside your repository. Edit it as required. You may check the validity of the yaml file online.
  • On top of your repository's README.md, put the following badge:
[![CI Build Status](https://github.com/<OWNER>/<REPO>/actions/workflows/build.yml/badge.svg)](https://github.com/<OWNER>/<REPO>/actions/workflows/build.yml)
  • Add, Commit and Push
  • See results of GitHub Actions @ https://github.com///actions/workflows/build.yml

How to use Anydesk to connect to remote network with low bandwidth usage

Anydesk is usually used for accessing remote desktop, viz. the entire GUI shell. This, however, uses a lot of data. If one wants to simply run commands remotely, then it's more efficient to use SSH by using Anydesk's TCP tunneling feature. TCP tunnelling also gives access to remote's network provided a SQUID web proxy is running @ remote, thus setting up a VPN effectively. Anydesk offers only one TCP tunneling in its FREE license.

To set up SSH, for example, to a Remote Linux server do the following:

  1. Setup Anydesk server in remote. Make sure Create TCP tunnels is checked in Settings > Permissions.
  2. Open Anydesk client in your Windows computer.
  3. Sign in to your Anydesk Account, otherwise TCP tunneling would be greyed out.
@SomajitDey
SomajitDey / Instruction.md
Created March 29, 2022 19:33 — forked from DestinyOne/Instruction.md
Letting ubuntu bash on Windows 10 run 'ssh -X' to get a GUI environment in a remote server

Letting Ubuntu bash on Windows 10 run 'ssh -X' to get a GUI environment on a remote server

  • First

Install all the following. On Window, install Xming. On Ubuntu bash, use sudo apt install to install ssh xauth xorg.

sudo apt install ssh xauth xorg
@SomajitDey
SomajitDey / sys_setup.md
Last active March 27, 2022 19:07
System setup checklist. Networking, SSH, webproxy, VNC, passwordless sudo etc.
  • Sudo without password
  • Setup necessary aliases in your server's .bashrc
    • alias x="nautilus ${PWD}" ; so that file explorer opens in current directory with command x
    • alias ls="ls -lt"
  • Seup git config name and email at your server
  • Setup terminal preferences
  • Networking
    • Expose server with tunnel. Make use of cron: crontab -e > @reboot tunnel -l /tmp/tunnel.log 22 and */1 * * * * tunnel -l /tmp/tunnel.log 22. Use tunnel because it is more or less portable and doesn't require sudo priviledge. Just install a portable socat in the same directory as tunnel (e.g. ~/.bin), if needed.
    • At your home-pc/laptop (client) setup a cronjob or add to ~/.bashrc : flock -n /tmp/tunnel.log tunnel -b <port> -l /tmp/tunnel.log <server-kid>:22
@SomajitDey
SomajitDey / ssh.conf
Last active March 26, 2022 02:55
How to alias user@hostname:port for SSH. As a .conf file inside /etc/ssh_config.d directory
# NOTE: You may simply put this config file inside /etc/ssh_config.d directory.
# Ref : https://www.howtogeek.com/75007/stupid-geek-tricks-use-your-ssh-config-file-to-create-aliases-for-hosts/
# To create ssh-keys easily use `ssh-keygen` @client followed by `ssh-copy-id server`
Host <alias>
User <uid>
HostName <ip or hostname>
Port <port>
IdentityFile <~/.ssh/your_saved_key> # for passwordless login
ServerAliveInterval 120
ServerAliveCountMax 30