Make my SSH alias
es prefer LAN over Internet but with a single command
#32
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently I have two explicit commands for both networks.
I am fine with the idea of having to specify MAC address or on what network is the given computer.
Tracked at Benjamin_Loison/FileZilla/issues/15.
+69
Related to #28.
Related to Benjamin_Loison/openssh/issues/37.
This could be used by being temporarily in 4G to test Internet access, notably concerning Benjamin_Loison/openssh/issues/20.
After talking about it with the person:
Could make a raspberry pi resolver at home but this would shift the problem to it.
Could just make an
alias
in~/.bashrc
trying to resolve, possibly with a time out of something like 2 seconds, the computer on current network and if not able to, then leverage Internet proxy.As proposed, DynDNS does not seem to help.
On my Fairphone 4 Termux:
Output:
No matter if connected to Cloudflare DNS or not, there is maybe some cache involving a bias.
As get same
nslookup
output on my flat wifi without Cloudflare DNS.Output:
Output:
So figuring out if the computer is available on current network seems to take at most about 0m0.119s which is fine.
I suspect that if I try to
ssh
and depending on exit status try with Internet proxy, then it may be bias by possible correct but broken or exitedssh
connection. Related to Benjamin_Loison/openssh/issues/39#note_569621.~/.bashrc
:>&2
is to support correctly piping to clipboard.Maybe it is useful to use
ssh ... exit
to be more precise instead ofping
.${@:3}
source: the Stack Overflow answer 9057392Being compatible with just targeting a given computer, no matter the running OS hostname would be nice.
#28 may help to have an absolute computer address no matter the running OS.
What about other protocols like SCP with
scp
and SSHFS withsshfs
?~/.bashrc
:For my work laptop:
~/.ssh/config
:Output:
For OverClock3000:
~/.ssh/config
:Output:
Shared for work at https://tchap.gouv.fr/#/room/!VKLBJRaIhzIdNCigmg:agent.education.tchap.gouv.fr/$T8n94GOoEMYNw7jK4SriMssKwhnjRsnhWb4Er7jBnzc.
Related to Benjamin_Loison/openssh/issues/53.
To support nickname, may have to write some kind of dict in
~/.bashrc
but I do not like this approach.alias
should not work I guess, at leats not cleanly.Current
ping
is not compatible with nicknames. Could tryssh
.Output:
Output:
Output:
Maybe because in https://livebox in DHCP I assigned an IP to my phone.
Output:
ssh root@ll
works fine.DuckDuckGo search add ssh timeout.
Output:
Source: the Stack Overflow answer 5255550
Output:
Output:
Source: the Stack Overflow answer 32389925
Output:
Could make my tool be called as
ssh
and makessh
available asssh_raw
orinitial_ssh
.Would be nice if it is a not configured connection, then it works as default
ssh
and possibly mention such.is still useful as:
Related to Benjamin-Loison/android/issues/156 and Benjamin_Loison/openssh/issues/16.
Related to Benjamin_Loison/xclip/issues/1#issuecomment-2578323.
Would help Benjamin_Loison/Remmina/issues/19.
Benjamin_Loison/openssh/issues/37 would help.
Related to the Tchap message:
scp
+ tab on Termux leads to network devices enumeration, this is to investigate.Output:
Related to Benjamin_Loison/seedvault/issues/43#issuecomment-2786526.
Output:
Output:
Output:
Output:
on Debian 12 GNOME laptop on the wifi of the hotel:
Output:
An alternative is to use
ssh -X CENSORED_other_network
or maybe modify~/.ssh/config
.Output:
If
CENSORED
does not match the hostname of the server, then it always use Internet proxy I guess, like currently as the proxy domain name is offline.Related to Benjamin_Loison/bash/issues/25.
Maybe can start the actual LAN SSH connection and figure out if it establishes correctly and if so print it and gives the end-user the connection access, otherwise try with Internet.
Bash script:
while for testing SSH connection passing
stdin
does not seem appropriate, but can't usestdin
later it seems.DuckDuckGo and Google search Bash function delay stdin usage.
Bash script:
Output:
So it consumes and captures
stdin
as wanted.I corrected accordingly #issuecomment-3000 but I can't explain why it seemed to have worked sometimes despite using this Bash function and not
ssh
.If do not pipe to the function, then it waits forever...
DuckDuckGo search Bash test if stdin.
Bash script:
Source: the Stack Overflow answer 2456870
Bash script:
Bash script:
Output:
I corrected the mentioned issue comment.
Putting in a variable
! -t 0
would be nice to avoid repeating it.So if run an unsuccessful command, it will try to reexecute it with Internet proxy which is unwanted.
Output:
an alternative is to append to the remote command
; exit 0
but then it means that we can't leverage the exit code, which may be acceptable.does not seem to easily enable me to find and modify the command, so let us assume that there is only the command as it is the case as far as I know how I use it currently. The possibly mistake safety seems quite fine, no option looks like
sudo rm -Rf /
for instance as far as I know.Not waiting the whole command execution before starting seeing its output would be nice.
Furthermore, we want to know what network is used for the connection before seeing the command output.
I verified that if do not specify a command, the Bash function works fine without any warning.
Bash script:
is an interesting start except that the output for local network is not prefixed by the used network.
-o ConnectTimeout=1
is in theory only for testing but may be needed, it is an issue as it returns an error and we don't want to just2> /dev/null
the command output as it may contain an important end-user payload:Python may help.