SSH Multiplexing
What is SSH multiplexing?
Section titled “What is SSH multiplexing?”Each time you run ssh, scp, sftp or rsync to Bunya, your computer normally opens a new connection and you must enter your password and your MFA code again.
SSH multiplexing lets you log in once. Your first connection stays open, and any further ssh, scp, sftp or rsync commands to Bunya use that same connection. You are not asked for your password or MFA code again while the first connection is open.
This is useful if you:
- work in several terminal windows on Bunya at the same time
- copy files with many separate
scporrsynccommands - run scripts on your own computer that connect to Bunya more than once
All sessions that share a connection are on the same Bunya login node as your first session. Use the hostname command to see which login node you are on.
Before you start
Section titled “Before you start”Which computers can use it?
Section titled “Which computers can use it?”| Your computer | Can use multiplexing? |
|---|---|
| Mac | Yes, using Terminal |
| Linux | Yes |
| Windows with WSL | Yes, from inside WSL |
Windows cmd or PowerShell |
No. The SSH client built into Windows does not support multiplexing. Please use WSL. |
| Windows with PuTTY | Yes, using PuTTY’s own setting. See PuTTY users. |
| Windows with WinSCP | Not needed. WinSCP already lets you transfer many files after a single MFA login. |
| Windows with MobaXterm | No. MobaXterm does not support multiplexing. |
Setting it up (Mac, Linux and WSL)
Section titled “Setting it up (Mac, Linux and WSL)”All of these steps are done on your own computer, not on Bunya.
Step 1: Create a folder for the connection files
Section titled “Step 1: Create a folder for the connection files”mkdir -p ~/.ssh/socketschmod 700 ~/.ssh ~/.ssh/socketsStep 2: Add Bunya to your SSH config file
Section titled “Step 2: Add Bunya to your SSH config file”Open the file ~/.ssh/config in a text editor (create it if it does not exist) and add the following lines.
Replace username with your Bunya username. UQ users use their UQ username. QCIF users use their QSAC username.
Host bunya HostName bunya.rcc.uq.edu.au User username ControlMaster auto ControlPath ~/.ssh/sockets/%C ControlPersist 1h ServerAliveInterval 60 ServerAliveCountMax 3Then make sure only you can read the file:
chmod 600 ~/.ssh/configWhat these lines do
Section titled “What these lines do”| Setting | What it does |
|---|---|
Host bunya |
A short name for Bunya. You can now type ssh bunya instead of ssh username@bunya.rcc.uq.edu.au |
HostName |
The address of Bunya |
User |
Your Bunya username |
ControlMaster auto |
Use the shared connection if one is open. If none is open, start one. |
ControlPath |
Where the shared connection file is kept. %C is replaced with a unique code made from your connection details. |
ControlPersist 1h |
Keep the shared connection open for 1 hour after your last session to Bunya closes |
ServerAliveInterval 60 and ServerAliveCountMax 3 |
Check every 60 seconds that Bunya can still be reached. Close the shared connection after 3 checks with no reply (about 3 minutes). |
You can make ControlPersist shorter (for example 15m) if you prefer. A shorter time means you will be asked to log in again more often.
Using it
Section titled “Using it”Always use the short name bunya in your commands.
If you type the full address, for example ssh username@bunya.rcc.uq.edu.au, the settings above are not used and you will be asked for your password and MFA code every time.
Log in the first time
Section titled “Log in the first time”ssh bunyaEnter your password and MFA code as normal. See the MFA section of Connecting to Bunya if you need help with this step.
Open more sessions
Section titled “Open more sessions”Open another terminal window on your computer and type:
ssh bunyaYou will be logged in straight away, with no password or MFA prompt.
Copy files
Section titled “Copy files”Copy a file from your computer to your Bunya scratch directory:
scp results.tar.gz bunya:/scratch/user/username/Copy a file from Bunya to the current folder on your computer:
scp bunya:/scratch/user/username/output.log .Copy a whole folder with rsync:
rsync -av mydata/ bunya:/scratch/user/username/mydata/Start an sftp session:
sftp bunyaNone of these commands will ask for your password or MFA code while the shared connection is open.
Checking and closing the shared connection
Section titled “Checking and closing the shared connection”Is the shared connection open?
Section titled “Is the shared connection open?”ssh -O check bunyaIf it is open you will see something like:
Master running (pid=12345)Close the shared connection
Section titled “Close the shared connection”ssh -O exit bunyaYou will see:
Exit request sent.ssh -O exit bunya closes every session that uses the shared connection. This includes any scp, sftp or rsync transfer that is still running. Wait for your transfers to finish first.
If you close the terminal window you used for your first login, the shared connection stays open in the background until the ControlPersist time runs out. Your other sessions keep working.
PuTTY users
Section titled “PuTTY users”PuTTY has its own connection sharing setting.
- Open PuTTY and load (or create) your saved session for
bunya.rcc.uq.edu.au. - In the left menu go to Connection … SSH.
- Tick Share SSH connections if possible.
- Go back to Session and click Save.
Log in with this saved session as normal. Any further PuTTY windows opened with the same saved session will log in without asking for your password or MFA code.
Keep the first PuTTY window open. Closing it ends the other PuTTY sessions that share its connection.
Troubleshooting
Section titled “Troubleshooting”I am still asked for my password and MFA code
Section titled “I am still asked for my password and MFA code”- Check that you typed
ssh bunyaand not the full address. - Check that the
Host bunyasection is above anyHost *section in~/.ssh/config. - Check that you are using Mac, Linux or WSL. The Windows
cmdand PowerShell SSH client does not support multiplexing.
ssh bunya hangs, or gives an error about the control socket
Section titled “ssh bunya hangs, or gives an error about the control socket”This can happen after your computer has been asleep, after you change network, or after your VPN disconnects.
- Run
ssh -O exit bunya. - If that does not work, delete the connection files and log in again:
rm -f ~/.ssh/sockets/*ssh bunyaBunya maintenance days
Section titled “Bunya maintenance days”Bunya is taken offline for maintenance on the second Tuesday of February, May, August and November. Your shared connection will be closed. Log in again once Bunya is back. See When Bunya is down for maintenance.
I want a separate connection that does not use the shared one
Section titled “I want a separate connection that does not use the shared one”ssh -S none bunyaThis opens a new, independent connection. You will be asked for your password and MFA code.
Still stuck?
Section titled “Still stuck?”Email rcc-support@uq.edu.au and include:
- your Bunya username
- where you are connecting from (e.g. campus, home, VPN)
- your operating system and the tool you are using (e.g. Mac Terminal, WSL, PuTTY)
- the output of
ssh -v bunya