Slack is a popular chat platform for developers and teams. It has a built-in IRC gateway that allows you to connect to other Slack teams and chat with them using your own IRC client. However, sometimes you may need to authenticate yourself to the Slack IRC gateway in order to join or join conversations. There are a few ways to do this. One way is to use the irssi command line tool. Another way is to use the Slack team’s authentication feature. Both of these methods require you to set up some environment variables before you can start using them. First, set up your environment variables: SLACK_TOKEN: Your Slack token (you can find it in your settings) IRSSI_USERNAME: Your username (you can find it in your settings) IRSSI_PASSWORD: Your password (you can find it in your settings) Next, set up the irssi command line tool: $ irssi -a “slack://ircgateway/login” -u “irssiuser” -p “irssipassword”


Also when working on a server or command line orientated environment, you might not have access to a web browser to login to Slack.

So running an IRC client with access to the gateway provided, is the supported solution and remedy for this. The rest of this post shows one relatively straight forward way of using irssi IRC chat client to connect and authenticate with the gateway.

Read this: Installing Fail2ban on Ubuntu 18.04 (Bionic Beaver)

1 – Enable IRC on Slack Team

In the Slack team’s web browser session navigate to:

1 – Enable IRC on Slack Team2 – Install irssiArch Linux3 – Run irssi4 – Slack Team Gateway Credentials5 – Add Slack Network Details6 – Add Slack Server Details7 – Save Default Slack Channels8 – Save Configuration9 – Run irssi

Team settings > Permissions > Gateways > Expand

Tick “Enable IRC gateway (SSL only)” and then click Save Settings.

XMPP as pictured can also be enabled here for services such as Jabber

2 – Install irssi

Arch Linux

The simplest most accessible way is by using the system’s package manager:

[alert-announce]

$ sudo pacman -S irssi

[/alert-announce]

Debian / Ubuntu

The simplest most accessible way is by using the system’s package manager:

[alert-announce]

$ sudo apt-get install irssi

[/alert-announce]

3 – Run irssi

Here are two methods, either on its own:

[alert-announce]

$ irssi

[/alert-announce]

Or in a screen session:

[alert-announce]

$ screen -S irssi-irc-client irssi

[/alert-announce]

4 – Slack Team Gateway Credentials

Navigate to the new page that contains your team’s Slack gateway credentials.

Account & Profile > Settings tab > Gateways > Gateway configuration Here are the details you need for the next few steps in order to setup IRC authentication to the Slack team.

Refer back to them as needed for these next steps.

5 – Add Slack Network Details

Where  is your Slack username, and loy-slack is the name you want the network to be remembered as.

[alert-announce]

/network add -nick loy-slack

[/alert-announce]

6 – Add Slack Server Details

Now add the server details to the network defined in the previous step, the command to do this comes next. Remember to replace loy-slack with the name you gave the network, and substitute the details from your Slack team’s IRC credentials into the command.

[alert-announce]

/server add -auto -ssl -network loy-slack . irc. slack. com 6667

[/alert-announce]

7 – Save Default Slack Channels

Entering this command will ensure irssi always joins the channel and network name whenever you connect to the server:

[alert-announce]

/channel add -auto #general loy-slack

[/alert-announce]

8 – Save Configuration

Save all changes to the irssi configuration file in your user’s Linux home directory.

[alert-announce]

/save

[/alert-announce]

Then quit the program:

[alert-announce]

/quit

[/alert-announce]

9 – Run irssi

Once again run the program as down in the earlier step:

[alert-announce]

$ irssi

[/alert-announce]

Or in a screen session:

[alert-announce]

$ screen -S irssi-irc-client irssi

[/alert-announce]

The below output or similar appears upon launch of irssi:

[alert-announce]

3:43 -!- Irssi: Looking up . irc. slack. com 13:43 -!- Irssi: Connecting to . irc. slack. com [52. 6. 30. 134] port 6667 13:43 -!- Irssi: Connection to . irc. slack. com established 13:43 slackbot [] requested CTCP VERSION from : 13:43 -!- IRC-SLACK gateway 13:43 -!- Welcome to Slack IRC Gateway server !~@10. 0. 23. 98 13:43 -!- MAP SILENCE=15 WHOX WALLCHOPS WALLVOICES USERIP CPRIVMSG CNOTICE MODES=6 MAXCHANNELS=100 SAFELIST are supported by this server 13:43 -!- NICKLEN=32 TOPICLEN=160 AWAYLEN=160 CHANTYPES=# PREFIX=(ov)@+ CHANMODES=b,k,l,rimnpst CASEMAPPING=rfc1459 are supported by this server 13:43 -!- there are 11 users 13:43 -!- Message of the day 13:43 -!- WELCOME TO SLACK… 13:43 -!- End of MOTD command 13:43 -!- Mode change [] for user :+i

[/alert-announce]

The persistent Slack connection is now setup and will be active each time you run irssi.