How to Properly Configure and Troubleshoot talk/talkd Service for Secure Server Communication


16 views

When attempting to set up an inter-user communication system using the classic UNIX talk protocol, many administrators encounter the frustrating "Connection refused" error. Let's break down the complete solution.

The talk system consists of two components:

1. talk (client)
2. talkd/in.talkd (server daemon)

The daemon must be properly configured through inetd or xinetd to handle incoming connections.

First, verify the required packages are installed:

# Debian/Ubuntu
sudo apt-get install talk talkd

# RHEL/CentOS
sudo yum install talk talk-server

The modern approach places configuration in /etc/inetd.conf.d/ rather than directly modifying /etc/inetd.conf. Create a new file:

sudo touch /etc/inetd.conf.d/talk
sudo chmod 644 /etc/inetd.conf.d/talk

Add these properly formatted entries:

# /etc/inetd.conf.d/talk configuration
talk    dgram   udp4   wait   root   /usr/sbin/in.talkd   in.talkd
ntalk   dgram   udp4   wait   root   /usr/sbin/in.ntalkd  in.ntalkd

After configuration changes:

# For systems using inetd
sudo killall -HUP inetd

# For systems using xinetd
sudo systemctl restart xinetd

Verify the service is listening:

netstat -tulnp | grep talkd
ss -ulnp | grep talkd  # Modern alternative

Ensure UDP ports 517 and 518 are open:

# For ufw
sudo ufw allow 517/udp
sudo ufw allow 518/udp

# For firewalld
sudo firewall-cmd --add-port=517/udp --permanent
sudo firewall-cmd --add-port=518/udp --permanent
sudo firewall-cmd --reload

From another terminal or host:

talk username@hostname

Successful connection should show both parties' terminals splitting with the message:

[Connection established]

If issues persist:

  1. Verify /etc/services contains:
    talk           517/udp
    ntalk          518/udp
  2. Check daemon permissions:
    ls -la /usr/sbin/in.talkd
    -rwxr-xr-x 1 root root 12345 Jan 1 00:00 /usr/sbin/in.talkd
  3. Test daemon execution:
    sudo /usr/sbin/in.talkd -d -n

For more secure alternatives to traditional talk:

# Secure shell-based talk
sudo apt-get install ytalk

# Terminal multiplexer-based chat
tmux new-session -s shared-chat

The UNIX talk and talkd utilities provide a simple way for users to communicate in real-time on the same system or across networked machines. This can be particularly useful in environments where personal devices aren't always available, and server-based communication is preferred.

When attempting to use talk mir@myhost.com, you might encounter:

[No connection yet]
───────[ Error on read from talk daemon: Connection refused. Press any key...]─────────────────────
[Checking for invitation on caller's machine]

Checking running processes reveals no talk daemon:

pgrep talk
pgrep talkd

The key configuration file is /etc/inetd.conf. The default entries should look like:

#:BSD: Shell, login, exec and talk are BSD protocols.
talk            dgram   udp    wait  nobody.tty       /usr/sbin/in.talkd      in.talkd
ntalk           dgram   udp    wait    nobody.tty     /usr/sbin/in.ntalkd     in.ntalkd

Common modifications include:

talk            dgram   udp4    wait root       /usr/sbin/in.talkd      in.talkd
ntalk           dgram   udp4    wait    root    /usr/sbin/in.ntalkd     in.ntalkd

On Ubuntu systems, there are two known problems:

  1. The talkd package incorrectly places its configuration in /etc/inetd.conf instead of /etc/inetd.conf.d
  2. The user.group format isn't properly handled by inetd

Here's a step-by-step fix:

# 1. Create or modify the configuration
sudo vi /etc/inetd.conf.d/talk

# 2. Add these contents (remove the nobody.tty format)
talk dgram udp4 wait root /usr/sbin/in.talkd in.talkd
ntalk dgram udp4 wait root /usr/sbin/in.ntalkd in.ntalkd

# 3. Restart inetd
sudo systemctl restart inetd

# 4. Verify the daemon is running
pgrep talkd

To verify everything works:

# On first terminal (as user1)
talk user2@localhost

# On second terminal (as user2)
talk user1@localhost

For secure communication:

  • Consider using SSH tunneling for talk sessions
  • Restrict access via firewall rules
  • Monitor talkd logs regularly

Example firewall rule:

sudo iptables -A INPUT -p udp --dport 517 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 518 -j ACCEPT