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.

umount /home device is busy

I wanted to unmount /home drive on a server.

If any program is accessing the drive, you won’t be able to unmount the disk. You need stop stop all process that use the drive.

To find the programs that use the /home partition, run

Or

This list all process, stop the process or kill it. Now you should be able to unmount the partition with

Run a script on boot using systemd on Ubuntu 18.04

Previous versions of Ubuntu had /etc/rc.local. that get executed after system boot.

On Ubuntu 18.04, you can use systemd to start a bash script on system boot.

Create file

Add

Create file /etc/rc.local with

You can replace “touch /root/OK” with whatever command you need to execute.

Make it executable with

Reload systemd

Enable the service

Now reboot the server, you will see /root/OK get created.