question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to use a SSH Config File

See original GitHub issue

Describe the feature I would like to suggest a new subnet detection feature that dynamically chooses a hostname/IP to connect to based on which network the app is running from, configured for each connection.

e.g. if I’m on my home network and the app detects I’m on a specified subnet such as 192.168.0.x, I would like the app to connect to a local IP address. If I’m connecting from a network other than the specified one (ie roaming on my iPhone), it uses another hostname such as an external URL (my.homenet.com).

I can illustrate this based on a method I use with .ssh/config (which as it happens also uses another feature request - ProxyJump)

Match exec "/Users/user1/onsubnet 192.168.1." host raspi1
 Hostname 192.168.1.100
 Port 22
 User pi

Match exec "/Users/user1/onsubnet --not 192.168.1." host raspi1
 ProxyJump proxypi
 Hostname 192.168.1.100
 User pi
 Port 22

Host proxypi
 HostName my.homenet.com
 Port 8700
 User pi

The file /Users/user1/onsubnet is a script I found that helps determine your subnet on a Mac. I realise it couldn’t be used in the app like this, but I’m including it here in case it helps.

if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]  || [[ "$1" == "" ]] ; then
  printf "Usage:\n\tonsubnet [ --not ] partial-ip-address\n\n"
  printf "Example:\n\tonsubnet 10.10.\n\tonsubnet --not 192.168.0.\n\n"
  printf "Note:\n\tThe partial-ip-address must match starting at the first\n"
  printf "\tcharacter of the ip-address, therefore the first example\n"
  printf "\tabove will match 10.10.10.1 but not 110.10.10.1\n"
  exit 0
fi

on=0
off=1
if [[ "$1" == "--not" ]] ; then
  shift
  on=1
  off=0
fi

regexp="^$(sed 's/\./\\./g' <<<"$1")"

if [[ "$(uname)" == "Darwin" ]] ; then
  ifconfig | fgrep 'inet ' | fgrep -v 127.0.0. | cut -d ' ' -f 2 | egrep "$regexp" >/dev/null
else
  hostname -I | tr -s " " "\012" | fgrep -v 127.0.0. | egrep "$regexp" >/dev/null
fi

if [[ $? == 0 ]]; then
  exit $on
else
  exit $off
fi

In the absence of this feature I could always specify the external URL, but I’m not sure if that would work with ProxyJump where a connection to an internal device would keep having to hop via my proxypi to its destination when I’m at home.

The other alternative would be to have two connections - one local and one remote. This would work fine, but it would be neater if I only needed to configure one host.

Hope this makes sense. Thanks.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
isonthelinecommented, Dec 13, 2022

Hi @jarrah31 👋

Thank you so much for your strong feedback!

I guess at the moment we still need to create a Connection as well as a config file entry? If so, perhaps the ability to automatically create new Connections if a Host entry within the ssh config file doesn’t match an existing Connection “Name”? This would help people easily import/migrate their ssh config file into WebSSH. Maybe a pop-up box after saving saying something like “detected new entry in ssh config file, do you want to create a new Connection?” If there’s are lots of new entries, maybe a “Yes to all” option would help?

You’re right WebSSH needs to have the connections created in order to work as it. Yes import from the SSH Config could be a great addition!

Only one drawback : Hosts with wildcard “*” won’t be imported

I’m creating an issue to track import from SSH Config File : https://github.com/isontheline/pro.webssh.net/issues/792

Support the “IdentityFile” keyword that translates to “Private key” within Connection settings? I have a few .ssh/config entries with these.

When implemented it should check within the “Keys inside WebSSH Settings UI” and if the key name has not been found it should check if a file exists named by the “IdentifyFile” parameter.

1reaction
akuropkacommented, Jul 12, 2021

oh well noted. (since I’m the IT I did not consider this… would be using two profiles then.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSH config file for OpenSSH client
The ssh program on a host receives its configuration from either the command line or from configuration files ~/.ssh/config and /etc/ssh/ssh_config .
Read more >
Using the SSH Config File | Linuxize
OpenSSH allows you to set up a per-user configuration file where you can store different SSH options for each remote machine you connect...
Read more >
SSH Client Config File Example - Teleport
This blog post will show you how to use SSH client config files to simplify server management.
Read more >
How to Manage an SSH Config File in Windows and Linux
Your SSH config file allows you to define specific settings for each SSH host that makes connecting to that host far easier.
Read more >
OpenSSH Config File Examples For Linux / Unix Users - nixCraft
Learn how to create an openssh config file to automate server login and create shortcuts for sshd server including advanced ssh client ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found