Skip to content

Instantly share code, notes, and snippets.

@thearchitect
thearchitect / create-hotspot.md
Created October 21, 2018 13:09 — forked from gowrav/create-hotspot.md
Create Wi-Fi Hotspot on Linux using nmcli

Create a Wi-Fi hotspot on Linux using nmcli

Original post : https://unix.stackexchange.com/a/310699

nmcli con add type wifi ifname wlx7cdd9046ee19 con-name AiRpaperHostspot autoconnect yes ssid AiRpaperHostspot
#Connection 'AiRpaperHostspot' (81bd8ff0-1473-4bda-b00d-5759cd1c3a27) successfully added.
nmcli con modify AiRpaperHostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify AiRpaperHostspot wifi-sec.key-mgmt none

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@thearchitect
thearchitect / tmux.sh
Created November 2, 2019 13:53 — forked from B-Galati/tmux.sh
tmux script example
#!/bin/bash
tmux has-session -t dev
if [ $? != 0 ]
then
tmux new-session -s dev -n "TEST" -d
tmux split-window -h -t dev:0
tmux split-window -v -t dev:0.1
tmux send-keys -t dev:0.0 'cd ~/foo/bar' C-m
tmux send-keys -t dev:0.1 'autossh -M 0 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" test@test -t "cd ~/bar;bash"' C-m