Adding External IP to the SSH Banner

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
BizarreAndroid
Posts: 2
Joined: Tue Feb 26, 2019 5:45 pm

Adding External IP to the SSH Banner

Post by BizarreAndroid » Sat Mar 16, 2019 11:12 pm

Hey so I've recently had a go at editing the dietpi-banner file (I hope no-one minds), I did it as I've got a few rpi's running dietpi on a few networks i.e. mine, my parents, and one of my friends houses. Was more of a little challenge I set myself to see if I can get it to work. Also because I have them as saves on my puTTy, so can be difficult to remember which is which. So now it is the usual banner, however under the IP Address line I have an additional one with the external IP. If anyone wants to know more or if the development team wants to implement it in a later version then feel free to message me or just fire away, i mean ofc you dont need my permission. I believe people may want it, not everyone I know, but some people might.
Just thought I'd share was a small achievement for me at least.

User avatar
MichaIng
Legend
Posts: 1256
Joined: Sat Nov 18, 2017 5:21 pm

Re: Adding External IP to the SSH Banner

Post by MichaIng » Sun Mar 17, 2019 12:14 am

It fits to our DietPi-Banner customization request: https://github.com/MichaIng/DietPi/issues/2627
No worries about modifying our scripts. It's GPLv2 licensed so you are free to any modifications and use the code in any way you want. Only limitation (not relevant for private purpose) is that if you publicly re-share modified files, they need to be licensed as GPLv2 as well and you need to name the original source and what you have changed ;).

The issue is that there is no reliable way to determine the external IP without manual input, is it?
/etc/hosts and /etc/hostname (respectively hostname command) "should" contain/match the external IP/domain, but it is not a must. One can successfully enable external access without changing the above content.

We have several software installs which require to know the external IP/domain but currently prompt an input field to enter it. I am already thinking about a proper solution to somehow ask user to enter the external IP and/or domain directly on first login (or via dietpi.txt) e.g., so we can use this info throughout our scripts non-interactively, but this again might be confusing for users which have a local-only setup.

So: It would be interesting to know how you obtain the external IP, not only to show it in the banner but as it is required in other cases as well.

baz123
Posts: 107
Joined: Thu Jan 12, 2017 8:23 pm

Re: Adding External IP to the SSH Banner

Post by baz123 » Fri Apr 05, 2019 7:58 pm

To get external IP:

Code: Select all

dig +short myip.opendns.com @resolver1.opendns.com

User avatar
MichaIng
Legend
Posts: 1256
Joined: Sat Nov 18, 2017 5:21 pm

Re: Adding External IP to the SSH Banner

Post by MichaIng » Fri Apr 05, 2019 8:19 pm

Has been implemented already (with v6.22). Run dietpi-banner from terminal and select WAN IP :). We placed an own most simply estimation script onto our server:
- https://github.com/MichaIng/DietPi/blob ... a/myip.php
- Get IP:

Code: Select all

curl -sLm 2 https://dietpi.com/myip.php

Post Reply