I would like to exchange on Freenode using ERC, however I do not know how to authenticate with SASL as required.

-xxxxxx.freenode.net- *** Lookup up your hostname...
-xxxxxx.freenode.net- *** Checking Ident
-xxxxxx.freenode.net- *** Found your hostname
-xxxxxx.freenode.net- *** No Ident response
-xxxxxx.freenode.net- *** Notice -- You need to identify via SASL to use
            this server

==> ERROR from irc.freenode.net: Closing Link:
xxxxxxxxxxxxxxxxxxxx.xx     (SASL access only)

Connection failed!  Not re-establishing connection.

*** ERC terminated: connection broken by remote peer

I looked quickly the ERC manual and the EmacsWiki website. I also noticed that Emacs has a SASL library. Moreover, a developer was proposing a SASL extension for ERC on a GitHub repository.

I am looking for a solution as well as an explanation (or overview) to facilitate a possible inspection of the source code. Eventually, you can specify how to proceed for other IRC clients (rcirc,...).

2 Answers 2


I ended up patching the erc-login function to use the SASL extension. I first installed this package https://github.com/joseph-gay/erc-sasl and added this to my init file:

(require 'erc-sasl)
(add-to-list 'erc-sasl-server-regexp-list "irc\\.freenode\\.net")

(defun erc-login ()
  "Perform user authentication at the IRC server. (PATCHED)"
  (erc-log (format "login: nick: %s, user: %s %s %s :%s"
           (or erc-system-name (system-name))
  (if erc-session-password
      (erc-server-send (format "PASS %s" erc-session-password))
    (message "Logging in without password"))
  (when (and (featurep 'erc-sasl) (erc-sasl-use-sasl-p))
    (erc-server-send "CAP REQ :sasl"))
  (erc-server-send (format "NICK %s" (erc-current-nick)))
   (format "USER %s %s %s :%s"
       ;; hacked - S.B.
       (if erc-anonymous-login erc-email-userid (user-login-name))
       "0" "*"

Jon2x answer didn't work for me. However, following ERC documentation: https://elpa.gnu.org/packages/doc/erc.html#SASL

User Option: erc-sasl-mechanism The name of an SASL subprotocol type as a lowercase symbol. The value can be one of the following:

plain and scram (“password-based”) Here, “password” refers to your account password, which is usually your ‘NickServ’ password. To make this work, customize erc-sasl-user and erc-sasl-password or specify the :user and :password keyword arguments when invoking erc-tls. Note that :user cannot be given interactively.

I wrote this funtion which uses authinfo and erc-tls to connect using sasl:

(defun salih/erc-connect ()
    "Connect to ERC with credentials from Authinfo."
  (let* ((auth-info (auth-source-search :host "irc.libera.chat"
                                        :require '(:user :secret)))
         (user-id (plist-get (car auth-info) :user))
         (password (funcall (plist-get (car auth-info) :secret))))
    (erc-tls       :user     user-id
                   :password password)))

It can be modified to be used without authinfo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.