Problem
If you are using Royal TSX on macOS and your SSH session disconnects after a few minutes of idle time, the problem is usually not your username, password, SSH key, or server login.
Most of the time, the session is being disconnected because the SSH connection becomes idle and some network device, firewall, VPN, router, NAT gateway, or server policy closes the inactive TCP connection.
This is a very common issue when working with Linux servers from macOS using Royal TSX.
Common Symptoms
You may see issues like:
- SSH session disconnects after 3–10 minutes of no typing
- Royal TSX terminal becomes frozen
- You come back after a short break and the session is gone
- Long-running commands stop if they were not running inside
tmuxorscreen - Normal terminal SSH may behave differently from Royal TSX
- The issue happens mostly when idle, not while actively typing
Why This Happens
SSH is a long-running network connection. When no data is sent for some time, firewalls, VPNs, routers, NAT gateways, cloud security devices, or server-side timeout policies may think the connection is inactive and close it.
To prevent this, the SSH client should send small keep-alive packets at regular intervals.
For Royal TSX, you should configure keep-alive inside the Royal TSX SSH connection settings.
For macOS OpenSSH, you can also configure keep-alive inside:
~/.ssh/config
Both settings are useful because Royal TSX may not always depend fully on your macOS OpenSSH config, depending on the terminal plugin being used.
Step 1: Enable SSH Keep Alive in Royal TSX
Open your saved SSH connection in Royal TSX.
Go to:
Royal TSX → SSH Connection → Properties / Edit
→ Advanced
→ Session
→ SSH Keep Alive Interval
Set the value to:
30
or:
60
Recommended value:
30
This means Royal TSX sends a keep-alive packet every 30 seconds to keep the SSH session active.
If the value is set to 0, keep-alive may be disabled.
Recommended Royal TSX Setting
SSH Keep Alive Interval = 30 seconds
This is usually the most effective fix.
Step 2: Configure macOS SSH Client Keep Alive
Now configure your macOS SSH client globally.
Open Terminal on your Mac and run:
mkdir -p ~/.ssh
nano ~/.ssh/config
Add the following configuration:
Host *
ServerAliveInterval 60
ServerAliveCountMax 3
TCPKeepAlive yes
Save the file.
In nano:
CTRL + O → Enter → CTRL + X
Then fix file permissions:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/config
What These Settings Mean
ServerAliveInterval 60
This tells your SSH client to send a keep-alive message every 60 seconds if no data is received from the server.
ServerAliveCountMax 3
This tells SSH to allow 3 missed keep-alive responses before disconnecting.
So with this setting:
60 seconds × 3 = around 180 seconds
If the server becomes unreachable for around 3 minutes, SSH disconnects.
TCPKeepAlive yes
This enables TCP-level keepalive.
However, ServerAliveInterval is usually more useful for SSH idle disconnect problems because it works at the SSH protocol level.
Step 3: Best Practice SSH Config Layout
If you already have GitHub or other SSH host entries, keep your specific hosts first and put Host * at the bottom.
Recommended structure:
# Default GitHub account
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
AddKeysToAgent yes
UseKeychain yes
# DevOps / Cotocus GitHub account
Host devops
HostName github.com
User git
IdentityFile ~/.ssh/cotocusin
IdentitiesOnly yes
AddKeysToAgent yes
UseKeychain yes
# Global default settings for all SSH connections
Host *
ServerAliveInterval 60
ServerAliveCountMax 3
TCPKeepAlive yes
Why put Host * at the bottom?
Because Host * applies to all SSH hosts. Keeping specific host entries first and general defaults at the end is cleaner and avoids unexpected behavior.
Step 4: Verify macOS SSH Config Is Working
Run this command from your Mac:
ssh -G your-server-ip-or-hostname | grep -Ei "serveralive|tcpkeepalive"
Example:
ssh -G 192.168.1.10 | grep -Ei "serveralive|tcpkeepalive"
Expected output:
serveraliveinterval 60
serveralivecountmax 3
tcpkeepalive yes
If you see this output, your macOS SSH client config is active.
Important note: this confirms normal OpenSSH behavior from macOS Terminal. Royal TSX may still need its own keep-alive setting enabled separately.
Step 5: Check If You Edited the Wrong SSH Config
Many users check this file on macOS:
/etc/ssh/sshd_config
But this file is for the SSH server running on your Mac.
That means it controls incoming SSH connections to your Mac, not outgoing SSH sessions from your Mac to another Linux server.
For your Royal TSX outgoing SSH issue, the important client-side file is:
~/.ssh/config
So this output on your Mac:
/etc/ssh/sshd_config:#ClientAliveInterval 0
/etc/ssh/sshd_config:#ClientAliveCountMax 3
does not fix Royal TSX outgoing SSH disconnects.
Also, because the lines start with #, they are commented and not active.
Step 6: Check the Remote Linux Server
If Royal TSX keep-alive and macOS SSH config do not solve the issue, check the remote Linux server.
SSH into the remote server and run:
sudo grep -Ei "ClientAlive|TMOUT" /etc/ssh/sshd_config /etc/profile ~/.bashrc ~/.profile 2>/dev/null
Also check the active SSH daemon config:
sudo sshd -T | grep -Ei "clientalive|tcpkeepalive"
Good server-side values are:
clientaliveinterval 300
clientalivecountmax 3
tcpkeepalive yes
If needed, edit the remote server SSH daemon config:
sudo nano /etc/ssh/sshd_config
Add or update:
ClientAliveInterval 300
ClientAliveCountMax 3
TCPKeepAlive yes
Then restart SSH.
For Ubuntu/Debian:
sudo systemctl restart ssh
For RHEL/CentOS/AlmaLinux/Rocky Linux:
sudo systemctl restart sshd
Be careful when restarting SSH on a remote server. Keep one existing session open while testing a new login in another window.
Step 7: Check Shell Auto Logout Using TMOUT
Sometimes SSH is not the real problem. The Linux shell itself may be configured to log out idle users.
Check this on the remote server:
echo $TMOUT
If it returns a number like:
300
then the shell may auto-logout idle users after 300 seconds.
Search where TMOUT is configured:
grep -R "TMOUT" /etc/profile /etc/bashrc /etc/profile.d/ ~/.bashrc ~/.profile 2>/dev/null
If this is a company-managed server, do not remove it without approval because it may be part of a security policy.
Step 8: Prevent Command Loss Using tmux
Even after fixing keep-alive, you should use tmux for long-running work.
Install tmux if needed.
Ubuntu/Debian:
sudo apt update
sudo apt install -y tmux
RHEL/CentOS/AlmaLinux/Rocky Linux:
sudo yum install -y tmux
Start a tmux session:
tmux new -s work
Run your long command inside tmux.
If SSH disconnects, reconnect and attach again:
tmux attach -t work
This prevents your running command from being killed when Royal TSX disconnects.
Useful tmux Commands
Create a new session:
tmux new -s work
Detach from tmux:
CTRL + B, then D
List sessions:
tmux ls
Reattach:
tmux attach -t work
Kill session:
tmux kill-session -t work
Step 9: macOS Sleep Settings
If your Mac goes to sleep, SSH will disconnect no matter how good your keep-alive settings are.
Check macOS settings:
System Settings → Battery → Options
Enable:
Prevent automatic sleeping when the display is off
Also check:
System Settings → Lock Screen
Make sure your Mac is not sleeping too quickly when idle.
Screen lock is usually fine. Full sleep is the problem.
Recommended Final Setup
For most users, this setup works well:
Royal TSX
SSH Keep Alive Interval = 30 seconds
macOS ~/.ssh/config
Host *
ServerAliveInterval 60
ServerAliveCountMax 3
TCPKeepAlive yes
Remote Linux Server
ClientAliveInterval 300
ClientAliveCountMax 3
TCPKeepAlive yes
For Long-Running Commands
Always use:
tmux
Complete Troubleshooting Checklist
Use this checklist if SSH still disconnects.
Client Side: macOS
Check SSH config:
cat ~/.ssh/config
Check permissions:
ls -ld ~/.ssh
ls -l ~/.ssh/config
Fix permissions:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/config
Verify active SSH options:
ssh -G your-server-ip-or-hostname | grep -Ei "serveralive|tcpkeepalive"
Expected:
serveraliveinterval 60
serveralivecountmax 3
tcpkeepalive yes
Royal TSX
Check:
SSH Connection → Advanced → Session → SSH Keep Alive Interval
Recommended:
30 seconds
Remote Server
Check active SSH daemon values:
sudo sshd -T | grep -Ei "clientalive|tcpkeepalive"
Check shell timeout:
echo $TMOUT
Search timeout config:
grep -R "TMOUT" /etc/profile /etc/bashrc /etc/profile.d/ ~/.bashrc ~/.profile 2>/dev/null
Network
If the issue still happens:
- Check VPN timeout
- Check office firewall timeout
- Check cloud firewall or bastion timeout
- Check router/NAT idle timeout
- Try from a different network
- Try direct macOS Terminal SSH and compare with Royal TSX
Final Conclusion
If Royal TSX SSH sessions disconnect after a few minutes of idle time on macOS, the best fix is to enable keep-alive in Royal TSX and also configure macOS SSH keep-alive.
The most practical configuration is:
Royal TSX SSH Keep Alive Interval = 30 seconds
and:
Host *
ServerAliveInterval 60
ServerAliveCountMax 3
TCPKeepAlive yes
If the session still disconnects, check the remote Linux server for ClientAliveInterval, ClientAliveCountMax, and shell-level TMOUT.
For production work, always use tmux so your commands continue running even if the SSH client disconnects.