Skip to content

Instantly share code, notes, and snippets.

View SomajitDey's full-sized avatar

Somajit SomajitDey

View GitHub Profile
@rxaviers
rxaviers / gist:7360908
Last active July 5, 2024 17:44
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@zentralwerkstatt
zentralwerkstatt / instructions.md
Last active July 5, 2021 18:58
SSH into Linux Subsystem for Windows
  • In /etc/ssh/sshd_conf, set UsePrivilegeSeparation to no
  • In /etc/ssh/sshd_conf, temporarily enable plaintext passwords
  • In /etc/ssh/sshd_conf, change port (e.g. to 23) to avoid confusion with Windows SSH server
  • sudo service ssh restart
  • Add alternative port as a new rule to Windows firewall
  • On the client: ssh-copy-id user@server
  • In /etc/ssh/sshd_conf, re-disable plaintext passwords

To fix Could not load host key ... error:

  • sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
@DestinyOne
DestinyOne / Instruction.md
Last active April 4, 2024 18:56
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
@dentechy
dentechy / WSL-ssh-server.md
Last active June 13, 2024 15:17
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on:
@imami
imami / anydesk-enable-remote-access.md
Last active July 2, 2024 04:04
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 / abs_path.bash
Last active September 26, 2021 16:11
Bash function to transform any Unix/Windows path to absolute Unix path
abs_path(){
# Transforms any path, including windows paths, given as parameter, to absolute path.
# Expands ~, ~-, \ etc.
# Exitcode: 0 (output to stdout) if path exists, 1 (outout to stderr) otherwise.
local path="${1}"
# Windows to Unix path [if operand is Unix path, then wslpath outputs to stderr]
local buffer=$(wslpath -u "${path}" 2>/dev/null); path="${buffer:-"${path}"}"
eval path="${path}" # Remove backslash, Tilde expansion etc.
[[ "${path}" != /* ]] && path="${PWD}/${path}"
@SomajitDey
SomajitDey / local_git_repo_cleanup.md
Last active September 26, 2021 16:10
Remove old commits and unnecessary objects form local (non-archive) repo to save on disk-space without affecting future updates: push/pulls

Remove old commits from local repo

Shallow fetch from self:

Keep only last n commits--

git fetch --depth=<n-1> . <branch>
@SomajitDey
SomajitDey / prompt.txt
Last active September 26, 2021 16:11
Bash and read -p prompts are sent to stderr...and more info
The readline prompt [read -p] is sent to stderr
The prompt for interactive bash is also sent to stderr. See POSIX mandate below
Source : https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
PS1 :: Each time an interactive shell is ready to read a command, the value of this
variable shall be subjected to parameter expansion and written to standard error.
NOTE (source- Bash reference manual):
@SomajitDey
SomajitDey / dump.bash
Last active March 26, 2021 20:00
Dump input stream at a given path
# This function dumps the input stream to the path given as parameter.
# If PATH gets unlinked by another (cooperative) process, it creates a new file at PATH and continues dump
# Provide a lockfile as the 2nd positional parameter. This is needed so that another process doesn't remove PATH
# when it is being written to.
stream_dump(){
declare -x path="${1}"
local lock="${2}"
local timeout="1" # Interval for polling $path
declare -x line
@SomajitDey
SomajitDey / fg_proc_list.bash
Last active September 26, 2021 16:10
Emulate job control signals from bash script
# First run the following 2 lines in your interactive bash attached to a controlling terminal
export bashpidfile="/tmp/bashpid" # File that stores the bash pid
export PROMPT_COMMAND='echo $$ > $bashpidfile' # Or, replace $$ with $BASHPID
# From another terminal do the following
### TPGID gives fg proc group on the tty the process is connected to, or -1 if the process is not connected to a tty
fgpg=$(ps --pid $(awk NR==1 $bashpidfile) -o tpgid=)
# Send signal SIG to all foreground processes to emulate user Ctrl- inputs
# Ctrl-C: INT, Ctrl-Z: TSTP, Ctrl-\: QUIT