run same command on multiple tmux panes

If you want to run same command on multiple servers, you can use tmux synchronize-panes feature. This will be useful when you need to setup multiple servers, say install nginx/php/mysql on multiple servers.

You can create multiple panes in tmux. SSH into each of the servers from these panes. Now run

Now type

Whatever command you run on one of the pane will be executed on all panes. Be careful when you run server specific commands.

tmux create new window on current directory

When you start a new window or split pane on tmux, it always start with the directory from where you run tmux command.

I prefer it start with current working directory of active tmux window. To do this, edit file

Add

Auto Attach to tmux session on SSH

To start tmux and attach to existing connection on SSH in, edit file

Add

Method 2

You can use following command when connecting to remote sevrer.

SSH Agent forwarding with tmux

Most of the time i connect to remote virtial machine to SSH to other servers. This way i will always have a fixed IP, so i can white list my IP in firewall. I use tmux on this server, so even if i get disconnected, my connection to these servers won’t get disconnected. This is useful when you running some commands that take long to finish.

On this VPS, i don’t keep my SSH keys for security reason, instead i use SSH Agent forwarding with ssh -A option. From my PC, i connect to sshbox with command

If i start a new tmux session, i will be able to login to other servers using my SSH key. If i attach to pre extsing tmux session, my SSH key won’t work. This is because SSH Agent use an environment variable SSH_AUTH_SOCK, this point to a sock file. When you get disconnected, it get deleted.

To fix this problem, edit ~/.tmux.conf file

Add

Create file

with following content

~/.ssh/rc file get executed every time a user connect using SSH. It will set symlink to SSH_AUTH_SOCK location if SSH agent forwarding is enabled.

Install OpenVPN Access Server

OpenVPN Access Server is paid version of OpenVPN with easy to use control panel. You can see license priceing at

https://openvpn.net/pricing/

First 2 users/devices are free to use. To install download the software from

https://openvpn.net/download-open-vpn/

On this page, you will see downloads for various operating systems.

Free OpenVPN Hosting

Install on CentOS 7

To install on CentOS 7, run

Example

You can set password for system user “openvpn” to access OpenVPN control panel.

Install on Debian 9

awk

To list all kernals available in your server, run

Example

bluetooth

To list bluetooth devices on Ubuntu, run

To list usb devices, run

“Cambridge Silicon Radio” is the USB device i have on my PC.