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](https://codeberg.org/Benjamin_Loison/FileZilla/issues/15).
+306
This could be used by being temporarily in 4G to test Internet access, notably concerning [Benjamin_Loison/openssh/issues/20](https://salsa.debian.org/Benjamin_Loison/openssh/-/issues/20).
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.
<details>
<summary>After talking about it with the person:</summary>
```
-----BEGIN PGP MESSAGE-----
hF4DTQa9Wom5MBgSAQdAjEk4CAOEN6Gf22csdaJEojX9mxG/Y+Xf8kNWyCx+7How
4jbzJF+RE6rbqw7Ur/5GYXpyzUVihy8cg/Rad59/1UoA4NuMdVUqt0SOkDnPr9rj
0kIBKV4mINiFTilj2lAKymtcFLmcgkUoQuu9QWnekFn1akInDkmd01kclpm3whwV
Oe5K1N5nZCrYVUR1kzbb8Ei8+8w=
=DFzK
-----END PGP MESSAGE-----
```
</details>
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.
alias Benjamin-Loison-HP_ssh='ssh Benjamin-Loison-HP_CENSORED'
time nslookup Benjamin-Loison-HP-Debian
echo$?
Output:
Server: 8.8.8.8
Address: 8.8.8.8#53
** server can't find Benjamin-Loison-HP-Debian: NXDOMAIN
real 0m0.054s
user 0m0.014s
sys 0m0.013s
1
No matter if connected to Cloudflare DNS or not, there is maybe some cache involving a bias.
On my Fairphone 4 Termux:
```bash
alias Benjamin-Loison-HP_ssh='ssh Benjamin-Loison-HP_CENSORED'
```
```bash
time nslookup Benjamin-Loison-HP-Debian
echo $?
```
<details>
<summary>Output:</summary>
```
Server: 8.8.8.8
Address: 8.8.8.8#53
** server can't find Benjamin-Loison-HP-Debian: NXDOMAIN
real 0m0.054s
user 0m0.014s
sys 0m0.013s
1
```
</details>
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.
time ping -c 1 Benjamin-Loison-HP-Debian
echo$?
Output:
PING Benjamin-Loison-HP-Debian.home (192.168.1.XXX) 56(84) bytes of data.
64 bytes from benjamin-loison-hp-debian.home (192.168.1.XXX): icmp_seq=1 ttl=64 time=71.8 ms
--- Benjamin-Loison-HP-Debian.home ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 71.876/71.876/71.876/0.000 ms
real 0m0.119s
user 0m0.000s
sys 0m0.020s
0
As get same `nslookup` output on my flat wifi without Cloudflare DNS.
```bash
time ping -c 1 Benjamin-Loison-HP-Debian
echo $?
```
<details>
<summary>Output:</summary>
```
PING Benjamin-Loison-HP-Debian.home (192.168.1.XXX) 56(84) bytes of data.
64 bytes from benjamin-loison-hp-debian.home (192.168.1.XXX): icmp_seq=1 ttl=64 time=71.8 ms
--- Benjamin-Loison-HP-Debian.home ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 71.876/71.876/71.876/0.000 ms
real 0m0.119s
user 0m0.000s
sys 0m0.020s
0
```
</details>
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 exited ssh connection. Related to Benjamin_Loison/openssh/issues/39#note_569621.
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 exited `ssh` connection. Related to [Benjamin_Loison/openssh/issues/39#note_569621](https://salsa.debian.org/Benjamin_Loison/openssh/-/issues/39#note_569621).
<details>
<summary><code>~/.bashrc</code>:</summary>
```bash
# [Benjamin_Loison/linux/issues/32](https://gitea.lemnoslife.com/Benjamin_Loison/linux/issues/32)
ssh_on_same_network_preferably()
{
sameNetworkAddress=$1
internetAddress=$2
if ssh $sameNetworkAddress exit 2> /dev/null
then
message='Same network connection'
reachableAddress=$sameNetworkAddress
else
message='Internet proxy'
reachableAddress=$internetAddress
fi
>&2 echo $message
ssh $reachableAddress "${@:3}"
}
```
</details>
`>&2` is to support correctly piping to clipboard.
Maybe it is useful to use `ssh ... exit` to be more precise instead of `ping`.
`${@:3}` source: [the Stack Overflow answer 9057392](https://stackoverflow.com/a/9057392)
Being 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.
Being 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.
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 try ssh.
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 try `ssh`.
ssh: connect to host fairphone-4-5g port 8022: No route to host
real 0m3.119s
user 0m0.005s
sys 0m0.009s
255
time ssh not_existing
echo$?
Output:
ssh: Could not resolve hostname not_existing: Name or service not known
real 0m0.021s
user 0m0.004s
sys 0m0.009s
255
Maybe because in https://livebox in DHCP I assigned an IP to my phone.
time ping -c 1 fairphone-4-5g
echo$?
Output:
PING fairphone-4-5g.home (192.168.1.XXX) 56(84) bytes of data.
From benjamin-loison-framework.home (192.168.1.XXX) icmp_seq=1 Destination Host Unreachable
--- fairphone-4-5g.home ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
real 0m3.079s
user 0m0.000s
sys 0m0.009s
1
```bash
time ssh pegasus exit; echo $?
```
<details>
<summary>Output:</summary>
```
real 0m0.339s
user 0m0.118s
sys 0m0.011s
0
```
</details>
```bash
time ssh fairphone-4-5g -p 8022
echo $?
```
<details>
<summary>Output:</summary>
```
ssh: connect to host fairphone-4-5g port 8022: No route to host
real 0m3.119s
user 0m0.005s
sys 0m0.009s
255
```
</details>
```bash
time ssh not_existing
echo $?
```
<details>
<summary>Output:</summary>
```
ssh: Could not resolve hostname not_existing: Name or service not known
real 0m0.021s
user 0m0.004s
sys 0m0.009s
255
```
</details>
Maybe because in https://livebox in DHCP I assigned an IP to my phone.
```bash
time ping -c 1 fairphone-4-5g
echo $?
```
<details>
<summary>Output:</summary>
```
PING fairphone-4-5g.home (192.168.1.XXX) 56(84) bytes of data.
From benjamin-loison-framework.home (192.168.1.XXX) icmp_seq=1 Destination Host Unreachable
--- fairphone-4-5g.home ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
real 0m3.079s
user 0m0.000s
sys 0m0.009s
1
```
</details>
Could make my tool be called as ssh and make ssh available as ssh_raw or initial_ssh.
Would be nice if it is a not configured connection, then it works as default ssh and possibly mention such.
Could make my tool be called as `ssh` and make `ssh` available as `ssh_raw` or `initial_ssh`.
Would be nice if it is a not configured connection, then it works as default `ssh` and possibly mention such.
```bash
alias fp4sshlocal='ssh -p 8022 _gateway'
```
is still useful as:
```bash
ssh _gateway -p 8022 exit
```
```
ignoring bad CNAME "_gateway" for host "_gateway": domain name "_gateway" starts with invalid character
```
```bash
ssh fairphone-4-5g -p 8022
```
```
ssh: Could not resolve hostname fairphone-4-5g: Name or service not known
```
Related to [Benjamin-Loison/android/issues/156](https://github.com/Benjamin-Loison/android/issues/156) and [Benjamin_Loison/openssh/issues/16](https://salsa.debian.org/Benjamin_Loison/openssh/-/issues/16).
Internet proxy
ssh: Could not resolve hostname _other_network: Name or service not known
```bash
ssh_on_same_network_preferably
```
<details>
<summary>Output:</summary>
```
Internet proxy
ssh: Could not resolve hostname _other_network: Name or service not known
```
</details>
Internet proxy
ssh: Could not resolve hostname CENSORED.ddns.net: No address associated with hostname
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
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.
```bash
ssh_on_same_network_preferably CENSORED
```
<details>
<summary>Output:</summary>
```
Internet proxy
ssh: Could not resolve hostname CENSORED.ddns.net: No address associated with hostname
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
```
</details>
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.
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.
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.
while for testing SSH connection passing stdin does not seem appropriate, but can't use stdin later it seems.
<details>
<summary>Bash script:</summary>
```bash
my_test()
{
cat
cat
}
echo test | my_test
```
</details>
```
test
```
while for testing SSH connection passing `stdin` does not seem appropriate, but can't use `stdin` later it seems.
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.
I corrected accordingly [#issuecomment-3000](#issuecomment-3000) but I can't explain why it seemed to have worked sometimes despite using this Bash function and not `ssh`.
So if run an unsuccessful command, it will try to reexecute it with Internet proxy which is unwanted.
```bash
ssh oc3k exit 0; echo $?
```
```
0
```
```bash
ssh oc3k exit 1; echo $?
```
```
1
```
So if run an unsuccessful command, it will try to reexecute it with Internet proxy which is unwanted.
...
EXIT STATUS
ssh exits with the exit status of the remote command or with 255 if an error occurred.
...
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.
```bash
man ssh
```
<details>
<summary>Output:</summary>
```
...
EXIT STATUS
ssh exits with the exit status of the remote command or with 255 if an error occurred.
...
```
</details>
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.
```bash
otherSshArguments="${@:2}"
```
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.
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.
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 just 2> /dev/null the command output as it may contain an important end-user payload:
ssh_on_same_network_preferably CENSORED_in-house
ssh: connect to host 10.1.XXX.XXX port 22: Connection timed out
Internet proxy
loison_benjamin@CENSORED-srv-02:~/ssd$
<details>
<summary>Bash script:</summary>
```bash
ssh_on_same_network_preferably()
{
sameNetworkAddress=$1
command=$2
if [ $# -eq 2 ]
then
command="$command; exit"
fi
if ssh -o ConnectTimeout=1 $sameNetworkAddress $command
then
message='Same network connection'
>&2 echo $message
else
message='Internet proxy'
>&2 echo $message
reachableAddress=${sameNetworkAddress}_other_network
ssh $reachableAddress $command
fi
}
```
</details>
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 just `2> /dev/null` the command output as it may contain an important end-user payload:
```
ssh_on_same_network_preferably CENSORED_in-house
ssh: connect to host 10.1.XXX.XXX port 22: Connection timed out
Internet proxy
loison_benjamin@CENSORED-srv-02:~/ssd$
```
Would help [Benjamin_Loison/Voice_assistant/issues/15#issuecomment-4906890](https://codeberg.org/Benjamin_Loison/Voice_assistant/issues/15#issuecomment-4906890).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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.
+306
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
aliasin~/.bashrctrying 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
nslookupoutput 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
sshand depending on exit status try with Internet proxy, then it may be bias by possible correct but broken or exitedsshconnection. Related to Benjamin_Loison/openssh/issues/39#note_569621.~/.bashrc:>&2is to support correctly piping to clipboard.Maybe it is useful to use
ssh ... exitto 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
scpand 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
~/.bashrcbut I do not like this approach.aliasshould not work I guess, at leats not cleanly.Current
pingis 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@llworks 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
sshand makesshavailable asssh_raworinitial_ssh.Would be nice if it is a not configured connection, then it works as default
sshand 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_networkor maybe modify~/.ssh/config.Output:
If
CENSOREDdoes 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
stdindoes not seem appropriate, but can't usestdinlater it seems.DuckDuckGo and Google search Bash function delay stdin usage.
Bash script:
Output:
So it consumes and captures
stdinas 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 0would 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 0but 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=1is 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/nullthe command output as it may contain an important end-user payload:Python may help.
Would help Benjamin_Loison/Voice_assistant/issues/15#issuecomment-4906890.
Illustrates Benjamin-Loison/gitea/issues/247.