1

I have a ssh script that looks like this.

#!/bin/bash

user="jumpuser"
host="??.??.??.??"
port="34"

x="ssh $user@$host -p $port "

x+="-L 8001:??.??.??.??:34 "    
# ...many more entries
x+="-L 8998:??.??.??.??:34 "                    

$x

We use this in my team to create a tunnel to reach certain services in our environment.

This was working perfectly fine, but today it started failing. The weird thing is it fails only for me. I get this error and no connection is made :

dup() in/out/err failed

Im on Mac OS, as everyone else, but im the only person having this issue and it started specifically today. I already rebooted my machine several times with no success.

  • It may not be the culprit here but `$x` is a fragile way to run a command. Please read [*How can we run a command stored in a variable?*](https://unix.stackexchange.com/q/444946/108618) – Kamil Maciorowski Dec 02 '20 at 13:56
  • 1
    You have reached the max number of opened files (file descriptors). This is only a comment because I know little about Macs; additionally I'm not sure if the error is from your local computer (SSH client) or the remote one (SSH server). Therefore I'm not going to write an answer. Anyway, research `ulimit` and such. These may help: [link 1](https://superuser.com/q/261023/432690), [link 2](https://unix.stackexchange.com/q/108174/108618). – Kamil Maciorowski Dec 02 '20 at 14:37
  • @KamilMaciorowski Thanks. I will try to dig on this – Matias Barrios Dec 02 '20 at 14:43
  • @KamilMaciorowski you were right. It was the ulimit and it was on my side. Thanks! Please post an answer and ill accept it – Matias Barrios Dec 02 '20 at 19:52
  • 1
    I only know `ulimit` exists but I'm not familiar with details. I'm not going to write an answer, it would be no better than my second comment which is a comment for a reason. If you want to [share your solution](https://superuser.com/help/self-answer) then go ahead. – Kamil Maciorowski Dec 02 '20 at 20:03

1 Answers1

2

What fixed this for me was this command :

ulimit -n 20000 24000

Just before running my script.