Skip to main content
added 4 characters in body
Source Link
Gilles 'SO- stop being evil'
  • 866.5k
  • 205
  • 1.8k
  • 2.3k

It is not possible to write a script in the configuration file to pull a variable for port number.

But you can write a bash function to get the port for you and place it into the correct place. For example place the following to the ~/.bashrc:

function ssh-dynamic() {
  PORT=`sh get_port_for_somehost.sh`
  exec ssh -p $PORT"$PORT" somehost $@"$@"
}

where the other configuration may stay in the ~/.ssh/config.

It is not possible to write a script in the configuration file to pull a variable for port number.

But you can write a bash function to get the port for you and place it into the correct place. For example place the following to the ~/.bashrc:

function ssh-dynamic() {
  PORT=`sh get_port_for_somehost.sh`
  exec ssh -p $PORT somehost $@
}

where the other configuration may stay in the ~/.ssh/config.

It is not possible to write a script in the configuration file to pull a variable for port number.

But you can write a bash function to get the port for you and place it into the correct place. For example place the following to the ~/.bashrc:

function ssh-dynamic() {
  PORT=`sh get_port_for_somehost.sh`
  exec ssh -p "$PORT" somehost "$@"
}

where the other configuration may stay in the ~/.ssh/config.

Source Link
Jakuje
  • 21.9k
  • 7
  • 56
  • 74

It is not possible to write a script in the configuration file to pull a variable for port number.

But you can write a bash function to get the port for you and place it into the correct place. For example place the following to the ~/.bashrc:

function ssh-dynamic() {
  PORT=`sh get_port_for_somehost.sh`
  exec ssh -p $PORT somehost $@
}

where the other configuration may stay in the ~/.ssh/config.