ZNC: Difference between revisions
No edit summary |
(Sunset) |
||
(18 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
=== ZNC will be sunset on 7 November, 2022. Please migrate to another service, like our The Lounge instance, which provides message history automatically. === |
|||
= Guide to ZNC = |
|||
This page describes client and server setup for ZNC with LDAP authentication. |
This page describes client and server setup for ZNC with LDAP authentication. |
||
For more info on ZNC, see [https://wiki.znc.in/ZNC]. |
If you're new to IRC, see [[How to IRC]] to get started. For more info on ZNC, see [https://wiki.znc.in/ZNC]. |
||
== ZNC setup == |
|||
These instructions show how to connect to the <code>#csc</code> channel on libera.chat via ZNC. |
|||
<ol> |
|||
<li> |
|||
Visit the ZNC web portal at [https://znc.csclub.uwaterloo.ca znc.csclub.uwaterloo.ca] and login using your CSC credentials. |
|||
</li> |
|||
<li> |
|||
Go to "Your Settings". Under "Networks", if you do not see a network called "libera", then click "Add", type "libera" for the Network Name, edit your nickname if desired, and enter the following into the IRC servers table: |
|||
<pre> |
|||
Hostname Port SSL |
|||
irc.libera.chat 6697 [Checked] |
|||
</pre> |
|||
</li> |
|||
<li> |
|||
(Optional, but recommended): Under the settings for libera, check the box which says "Connect to IRC & automatically re-connect". This will connect you to Libera as soon as you connect to ZNC. |
|||
</li> |
|||
<li> |
|||
Set your nick, alt. nick, and ident for libera. Make sure these all have the same value. By default these are set to %user% which will expand to your csc username. |
|||
If you are already logged in to libera with your csc username on a different IRC client, make sure to change your nick here |
|||
as two different connections cannot share the same nick. |
|||
</li> |
|||
<li> |
|||
Under the "channels" section for libera, click "Add", then enter <code>#csc</code> in the "Channel Name" field, and check the boxes "Save to config", "Detached", and "Enabled". Click "Add Channel and return". |
|||
</li> |
|||
</ol> |
|||
Now you will connect to ZNC with an IRC client. |
|||
== IRC Client setup == |
|||
=== The Lounge (chat.csclub.uwaterloo.ca) === |
|||
<ol> |
|||
<li> |
|||
Under network settings, name can be anything you want. |
|||
</li> |
|||
<li> |
|||
Server should be set to <code>znc.csclub.uwaterloo.ca</code>, and port <code>6697</code>. The password is <code><zncusername>:<zncpassword></code>. If you have multiple networks configured, i.e. Libera and Freenode, use <code><zncusername>/<networkname>:<zncpassword></code> for the password. Also set your nick, username and real name. |
|||
</li> |
|||
<li> |
|||
Under Authentication, choose <code>Username + password (SASL PLAIN)</code>, and enter your LIBERA nick and password. |
|||
</li> |
|||
</ol> |
|||
=== Weechat === |
|||
<ol> |
|||
<pre> |
|||
/server add myznc znc.csclub.uwaterloo.ca/6697 -username=<CSC_USERNAME>/libera -password=<CSC_PASSWORD> -ssl -autoconnect |
|||
/connect myznc |
|||
/join #csc |
|||
</pre> |
|||
Don't forget to concatenate "/libera" to the end of your username. |
|||
<li> |
|||
If you did not check the autoconnect box, you will need to manually connect using: |
|||
<pre> |
|||
/msg *status connect |
|||
</pre> |
|||
To verify that you are connected to Libera, run |
|||
<pre> |
|||
/msg *status ListNetworks |
|||
</pre> |
|||
The "IRC" column should have the value "Yes". |
|||
</li> |
|||
<li> |
|||
A modified version of the backlog module [https://wiki.znc.in/Backlog] is enabled globally. To use this, first enable the <kbd>log</kbd> module for your user via the web UI. You will then be able to request older logs for a channel from your IRC client, e.g. |
|||
<pre> |
|||
/msg *backlog #csc 42 |
|||
</pre> |
|||
Note that you do <b>not</b> need to specify the log path. |
|||
</li> |
|||
</ol> |
|||
== Server setup == |
== Server setup == |
||
Note that the following instructions are about setting up a ZNC instance with support for LDAP authentication, similar to the CSC ZNC, and it is ''not'' about configuring an IRC client to connect to ZNC. For that, see the [[ZNC#Client_setup|Client setup]] section above. |
|||
=== Saslauthd setup === |
|||
=== saslauthd setup === |
|||
For LDAP authentication, we use the Cyrusauth module [https://wiki.znc.in/Cyrusauth], which needs to communicate with the SASL authentication daemon (saslauthd). |
For LDAP authentication, we use the Cyrusauth module [https://wiki.znc.in/Cyrusauth], which needs to communicate with the SASL authentication daemon (saslauthd). |
||
<ol> |
<ol> |
||
Line 72: | Line 144: | ||
/server add myznc <SERVER_IP>/<PORT> -username=<ADMIN_USERNAME> -password=<ADMIN_PASSWORD> |
/server add myznc <SERVER_IP>/<PORT> -username=<ADMIN_USERNAME> -password=<ADMIN_PASSWORD> |
||
/connect myznc |
/connect myznc |
||
/msg *Cyrusauth CreateUsers yes |
|||
/alias add znc /quote znc |
|||
/znc *Cyrusauth CreateUsers yes |
|||
</pre> |
</pre> |
||
This will tell ZNC to create a new user on their first login. |
This will tell ZNC to create a new user on their first login. |
||
</li> |
|||
<li> |
|||
You may optionally wish to create users from a template (i.e. dummy) user to share some common per-user settings, such as MaxNetworks. To do this, login to the ZNC web interface as admin and click on "Manage Users". Add a new user called "dummy" with the desired settings, then click "save". |
|||
Now open Weechat, login to ZNC as admin, and run the following: |
|||
<pre> |
|||
/msg *Cyrusauth CreateUsers clone dummy |
|||
</pre> |
|||
This will tell ZNC to clone new users using "dummy" as the template. |
|||
</li> |
|||
<li> |
|||
You may wish to optionally enable the adminlog module [https://wiki.znc.in/Adminlog] so that you can see who has logged in from where at what time. By default, these logs will be written to a file. To prevent this file from growing too long, install logrotate and paste the following into /etc/logrotate.d/znc: |
|||
<pre> |
|||
/home/znc/.znc/moddata/adminlog/znc.log { |
|||
rotate 4 |
|||
weekly |
|||
compress |
|||
} |
|||
</pre> |
|||
This will keep rotate logs every week, discarding logs after they have been rotated 4 times. |
|||
</li> |
</li> |
||
</ol> |
</ol> |
||
=== NGINX tuning === |
|||
If you are running ZNC behind NGINX as a reverse proxy, keep in mind that by default, NGINX will run one worker process per CPU core. To reduce this, change the following in <kbd>/etc/nginx/nginx.conf</kbd>: |
|||
<pre> |
|||
worker_processes 4 |
|||
</pre> |
Latest revision as of 12:52, 1 November 2022
ZNC will be sunset on 7 November, 2022. Please migrate to another service, like our The Lounge instance, which provides message history automatically.
This page describes client and server setup for ZNC with LDAP authentication. If you're new to IRC, see How to IRC to get started. For more info on ZNC, see [1].
ZNC setup
These instructions show how to connect to the #csc
channel on libera.chat via ZNC.
- Visit the ZNC web portal at znc.csclub.uwaterloo.ca and login using your CSC credentials.
-
Go to "Your Settings". Under "Networks", if you do not see a network called "libera", then click "Add", type "libera" for the Network Name, edit your nickname if desired, and enter the following into the IRC servers table:
Hostname Port SSL irc.libera.chat 6697 [Checked]
- (Optional, but recommended): Under the settings for libera, check the box which says "Connect to IRC & automatically re-connect". This will connect you to Libera as soon as you connect to ZNC.
- Set your nick, alt. nick, and ident for libera. Make sure these all have the same value. By default these are set to %user% which will expand to your csc username. If you are already logged in to libera with your csc username on a different IRC client, make sure to change your nick here as two different connections cannot share the same nick.
-
Under the "channels" section for libera, click "Add", then enter
#csc
in the "Channel Name" field, and check the boxes "Save to config", "Detached", and "Enabled". Click "Add Channel and return".
Now you will connect to ZNC with an IRC client.
IRC Client setup
The Lounge (chat.csclub.uwaterloo.ca)
- Under network settings, name can be anything you want.
-
Server should be set to
znc.csclub.uwaterloo.ca
, and port6697
. The password is<zncusername>:<zncpassword>
. If you have multiple networks configured, i.e. Libera and Freenode, use<zncusername>/<networkname>:<zncpassword>
for the password. Also set your nick, username and real name. -
Under Authentication, choose
Username + password (SASL PLAIN)
, and enter your LIBERA nick and password.
Weechat
-
If you did not check the autoconnect box, you will need to manually connect using:
/msg *status connect
To verify that you are connected to Libera, run
/msg *status ListNetworks
The "IRC" column should have the value "Yes".
-
A modified version of the backlog module [2] is enabled globally. To use this, first enable the log module for your user via the web UI. You will then be able to request older logs for a channel from your IRC client, e.g.
/msg *backlog #csc 42
Note that you do not need to specify the log path.
/server add myznc znc.csclub.uwaterloo.ca/6697 -username=<CSC_USERNAME>/libera -password=<CSC_PASSWORD> -ssl -autoconnect /connect myznc /join #csc
Don't forget to concatenate "/libera" to the end of your username.
Server setup
Note that the following instructions are about setting up a ZNC instance with support for LDAP authentication, similar to the CSC ZNC, and it is not about configuring an IRC client to connect to ZNC. For that, see the Client setup section above.
saslauthd setup
For LDAP authentication, we use the Cyrusauth module [3], which needs to communicate with the SASL authentication daemon (saslauthd).
-
On the server, install the following packages:
apt install sasl2-bin ca-certificates
-
Open /etc/default/saslauthd, and change the following lines:
START=yes MECHANISM="ldap"
-
Paste the following into /etc/saslauthd.conf:
ldap_servers: ldaps://auth1.csclub.uwaterloo.ca ldaps://auth2.csclub.uwaterloo.ca ldap_search_base: ou=People,dc=csclub,dc=uwaterloo,dc=ca ldap_filter: (uid=%u)
-
Start saslauthd:
# service saslauthd start
-
Test saslauthd to make sure it's working:
$ testsaslauthd -u "your_csc_username" -p "your_csc_password"
You should see a response like
0: OK "Success."
ZNC setup
-
Install ZNC:
# apt install znc
-
Add a user for ZNC and create an initial configuration:
# useradd -s /bin/bash -m znc # usermod -a -G sasl znc # su - znc $ znc --makeconf
Note that the znc user must be part of the sasl group to communicate with saslauthd.
- Visit the web interface at <SERVER_IP>:<PORT>. Note that you may need to modify your browser settings so that you can visit a website at port 6667 or 6697.
- Log in using your admin credentials, then go to "Global Settings". Check the "cyrusauth" box, type "saslauthd" in the arguments input field, then scroll to the bottom and click "Save".
-
You will now need to connect to ZNC with an IRC client. The commands below assume Weechat is being used, but other clients should be similar.
/server add myznc <SERVER_IP>/<PORT> -username=<ADMIN_USERNAME> -password=<ADMIN_PASSWORD> /connect myznc /msg *Cyrusauth CreateUsers yes
This will tell ZNC to create a new user on their first login.
-
You may optionally wish to create users from a template (i.e. dummy) user to share some common per-user settings, such as MaxNetworks. To do this, login to the ZNC web interface as admin and click on "Manage Users". Add a new user called "dummy" with the desired settings, then click "save".
Now open Weechat, login to ZNC as admin, and run the following:
/msg *Cyrusauth CreateUsers clone dummy
This will tell ZNC to clone new users using "dummy" as the template.
-
You may wish to optionally enable the adminlog module [4] so that you can see who has logged in from where at what time. By default, these logs will be written to a file. To prevent this file from growing too long, install logrotate and paste the following into /etc/logrotate.d/znc:
/home/znc/.znc/moddata/adminlog/znc.log { rotate 4 weekly compress }
This will keep rotate logs every week, discarding logs after they have been rotated 4 times.
NGINX tuning
If you are running ZNC behind NGINX as a reverse proxy, keep in mind that by default, NGINX will run one worker process per CPU core. To reduce this, change the following in /etc/nginx/nginx.conf:
worker_processes 4