Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Wednesday, November 16, 2022

Tmux : Create multiple windows to ssh to several servers

 #!/usr/local/bin/zsh

SESSION="Maintenance-X"

tmux new -s "${SESSION}" -d
tmux rename-window -t "${SESSION}.0" Main
tmux new-window -d -t "${SESSION}" -n Server1
tmux new-window -d -t "${SESSION}" -n Server2
tmux new-window -d -t "${SESSION}" -n Server3

# Run ssh command in each window
tmux send-keys -t "${SESSION}:1" 'ssh server1.mydomain' Enter
tmux send-keys -t "${SESSION}:2" 'ssh server2.mydomain' Enter
tmux send-keys -t "${SESSION}:3" 'ssh server3.mydomain' Enter

# To run command in a pane within a window, use:
# tmux send-keys -t "${SESSION}:1.<pane-position>" 'ssh server1' Enter
# tmux send-keys -t "${SESSION}:1.top" 'ssh server1' Enter


tmux attach-session -d -t "$SESSION"

Sunday, October 17, 2021

Creating a user service on Linux

 This is an example of running a local python script as a user service.

Most of this information was found  here.


Service location:

/home/user/.config/systemd/servicename.service


Service definition/contents of servicename.service

[Unit]
Description=Metriful User Service

[Service]
ExecStart=/usr/bin/python3 /home/user/script.py
Restart=on-failure

[Install]
WantedBy=default.target


Reload Systemd so it can find the new service

systemctl --user daemon-reload


Enable Service with

systemctl --user enable servicename.service


Let Service run even when all user sessions have expired

loginctl enable-linger <user>

Monday, October 11, 2021

ZSH First time run

These are the commands to re-run ZSH first time setup.


autoload -Uz zsh-newuser-install
zsh-newuser-install -f

Friday, March 18, 2011

Configuring OpenVPN on FreeBSD [Quick Guide]

[Note: This post is a work in progress.]

pkg_add -r openvpn

rehash

mkdir -p /usr/local/etc/openvpn
cd /usr/local/etc/openvpn
touch openvpn.conf

cp -R /usr/local/share/doc/openvpn/easy-rsa .

cd easy-rsa/2.0/

[Edit the vars file to reflect your details. This will save you the trouble of having to type your organisation's details every time you generate a certificate. You may also need to change your shell to sh to execute the scripts. I also had to do a chmod +x * in that directory.]

./clean-all
./vars
./build-ca

[Generate Server Key named server1]
./build-key-server server1

[Generate Keys for clients]
./build-key hpserver
./build-key acerlaptop

[Generate Diffie-Hellman keys]
./build-dh


#The following keys have been copied from /usr/local/etc/openvpn/easy-rsa/2.0/keys


ca /usr/local/etc/openvpn/keys/ca.crt
cert /usr/local/etc/openvpn/keys/server.crt
key /usr/local/etc/openvpn/keys/server.key
dh /usr/local/etc/openvpn/keys/dh1024.pem


Now, edit openvpn.conf (on the server-end) as follows. Substitute IP addresses as required.

[OpenVPN Server Config]
#Configuration of OpenVPN Server

port 1194
proto tcp
dev tun

ca keys/ca.crt
cert keys/server.crt
key keys/server.key

dh keys/dh1024.pem


server 10.0.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt


client-config-dir ccd #Client specific settings, e.g. Fixed IP Addresses
client-to-client #Allow clients to communicate with each other

push "route 192.168.0.0 255.255.0.0"

keepalive 60 120

comp-lzo
persist-key
persist-tun

status open-status.log
verb 3



Copy the generated client keys to /etc/openvpn/. You will need to copy, for example, acerlaptop.crt, acerlaptop.key and ca.crt and mentioned them in openvpn.conf on the client as follows.



[OpenVPN Client Config]
#Configuration of OpenVPN Client

client
dev tun
proto tcp

remote openvpn.dyndns.org 1194 #public ip address and port of vpn server

nobind
persist-key
persist-tun

#client certificates
ca ca.crt
cert acerlaptop.crt
key acerlaptop.key
ns-cert-type server
comp-lzo
verb 3


[Auto-start openvpn]
Add the following in /etc/rc.conf on the server.

openvpn_enable="YES"

If not already present, also add the following knob in /etc/rc.conf to allow the server to route between your LAN and VPN subnets.  

gateway_enable="YES"

Note: Some documentation propose adding if_tun_load="YES" to /boot/loader.conf. I found that is not necessary. Openvpn will start the required device drivers automatically. You can try adding it, if openvpn fails to start or dynamically start it at a prompt by issuing kldload if_tun.

---

The OpenVPN documentation provides more in depth explanation. It can be viewed at : http://openvpn.net/index.php/open-source/documentation/howto.html.

Tuesday, May 25, 2010

Fedora 13 is out


Fedora 13 is finally out after 2 weeks (or so!) of delay. It looks great - feature wise. I haven't had time to try it yet, but a review will come as soon as I find some time to test it.

Download it at http://fedoraproject.org/en/get-fedora

Wednesday, May 05, 2010

Fedora 13 Goddard

Fedora 13 "Goddard" is due is 14 days. After the renewed disappointment that was Ubuntu 10.04, I can't wait to get Fedora 13 up and running. Fedora 12 is running full-time on both my servers and on my laptop - uptime of more than 5 months (on the server). Hehe :D

Go for Goddard!

Thursday, October 08, 2009

Ubuntu 9.10

Lo and Behold! After the great success of Ubuntu 9.04, codenamed Jaunty Jackalope, Ubuntu 9.10 is about release in 20 days time. Codenamed Karmic Koala, it features many new improvements and additions.

Can't wait? Download the BETA version here.

Check out the New Features here.

Monday, April 16, 2007

Fedora Core 6 (Zod) : Not Upto Expectations!!!

After downloading the DVD of FC6 (codenamed Zod) for 2 weeks I pretty disappointed by what I got. I did a nearly complete install of the thing since I am involved in development and web technologies a lot as a student in Telecommunications Engineering.

The first sight of the new interface and loading screen and all those very fine and polished graphics based on the DNA was more than amazing. Half of my thirst for Zod was blissfully quenching after experiencing this new and much refined system.

As soon as I logged in I tried to remove some software which I won't use and add others! To my great surprise, Zod won't allow me access to the software list without an internet connection!!! What the heck!? DO you need an internet connection to remove software! So, I switched on my wireless LAN card (I had FC6 set on my laptop). And the indicator lights for the card won't light up!! Ooops!! I check out the Device Manager - my card is well recognized but for some reason FC6 won't enable it! I can't even add new softwares for the DVD, it will ask me for repo0 or something. They such a mess out of what used to be a simple operating system. My first experience with Linux was Red Hat 8 and 9 years ago, on which FC is now based.

OK fine, let's move one and explore a bit more. I try enabling the Desktop Effects! It tells me it cannot enable it. This is utterly impossible since I do have a powerful enough graphics card on my laptop - an ATI mobility X1600 with 512MB HyperMemory. SO i say let's install the graphics drivers and to my even greater shock, my whole linux system crashed afterwards! The drivers worked fine in my other system, such as Ubuntu and Knoppix.

SO, obviously, after much dissatisfaction of Zod, I switched back to Ubuntu, which I dare rate as the premium Linux OS, after what I would call the fall the FC6. I am much disappointed! But still very satisfied with Ubuntu and Knoppix.

If you want to give it a try and test it, here's the homepage of FC6:

http://fedoraproject.org/wiki/

I hope you are luckier than me.