Connect RDP through a SSH Tunnel

My desktop is behind a router I don’t have access to, but I wanted to be able to RDP into it.

After some searching I found this article about how to do just that!
https://eviatargerzi.medium.com/how-to-access-rdp-over-ssh-tunnel-c0829631ad44

I already had a instance of lightsail on AWS so I just used it.

ensure openssh-server is installed, if not:

sudo apt update
sudo apt install openssh-server

Edit the sshd_config

sudo vim /etc/ssh/sshd_config

scroll to the bottom. Type “i” for insert then add the following lines

#Allow RDP Tunneling
GatewayPorts=clientspecified

To save: esc then “:wq” (command, wright, quit)

You can check that it’s in there by running

cat /etc/ssh/sshd_config | grep Gate

response:

#GatewayPorts no
GatewayPorts=clientspecified

Configure RDP Host

Eviatar suggests using Plink(Putty Link) on your host computer

Download: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

After installation, you may need to set the path.

You may be able to run

set PATH='C:\Program Files\PuTTY\plink.exe'

Close and reopen command prompt. If that doesn’t work, from the start menu search bar look for “environment variables” and open “Edit the System Environmental Variables”

Click “Environment Variables…” button under the Advanced Tab

Under “User variables” select “Path” then click edit

Click new and add C:\Program Files\PuTTY\plink.exe

Click OK, then restart command prompt and type plink to see if the system found it.

plink <user>@<ip or domain> -i <c:/users/user/.ssh/private_key_from_aws> -P 22 -2 -4 -T -N -C -R 0.0.0.0:12345:127.0.0.1:3389

-i – Set key location
-P – Set port
-2 – Force protocol version
-4 – Force use of IPv4 (and not IPv6)
-T – disable putty from attempting to allocate a pseudo-terminal at the server
-N – Prevents Putty from attempting to start a shell or command on the remote server
-C – Enables compression
-R – forward remote port to local address: Here port 12345 will be forwarded to 3389

This can be simplified using OpenSSH

Follow instructions from microsoft to install:
https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=gui

  #aws server
  Host 123.123.123.123
    User bitnami
      IdentityFile ~/.ssh/id_rsa
      IdentitiesOnly yes
      ServerAliveInterval 60
      ServerAliveCountMax 10

Adding ServerAliveInterval sets the number of seconds the client will wait before sending a packet to the server to keep connection alive

ServerAliveCountMax sets the number of times the client will try to keep connection alive.

You can also add ClientAliveInterval to etc/sshd/ssh_config on the server

ClientAliveInterval 60
ClientAliveCountMax 10 #default is 3

Be sure to open up 3389 on your server’s firewall

ssh 123.123.123.123 -2 -4 -T -N -C -R 0.0.0.0:12345:127.0.0.1:3389

Install NPM & Node on Windows

NPM documentation suggests installing from NVM since the node installer could cause permission issues down the line.

There’s an nvm port: https://github.com/coreybutler/nvm-windows

Once installed, open a terminal window (or close and reopen)

nvm install node

Search for Environmental Variables in Windows Search. This will open System Settings, click Environmental Variable, Edit “Path”, Create new and browse to your nvm install location for me it was C:\Users\USER\AppData\Roaming\nvm\v19.9.0

Save, then close your terminal window and open it again, so the new paths update.

npm --version


Running old wordpress themes on Lightsail

I do not recommend continuing to use PHP 5.6. It’s full of vulnerabilities, but I needed to buy myself some time with some old WordPress themes that error out on higher version of php.

Stop bitnami services and save the instance as a backup

sudo /opt/bitnami/ctlscript.sh stop
sudo mv /opt/bitnami /opt/bitnami.back

Download and install archived instance (check the Bitnami changelog to find if you need a different version, then just update the numbers accordingly)

cd /tmp
curl -LO https://downloads.bitnami.com/files/stacks/wordpress/4.8.2.php56-0/bitnami-wordpress-4.8.2.php56-0-linux-x64-installer.run

chmod +x bitnami-wordpress-4.8.2.php56-0-linux-x64-installer.run
sudo ./bitnami-wordpress-4.8.2.php56-0-linux-x64-installer.run

for PHP 7 useupl

 curl -LO https://downloads.bitnami.com/files/stacks/wordpress/5.9.1-0/bitnami-wordpress-5.9.1-0-linux-x64-installer.run

The newest version (at writing) using PHP8 is 6.1.1-0 and can be downloaded:

curl -LO https://downloads.bitnami.com/files/stacks/wordpress/6.1.1-0/bitnami-wordpress-6.1.1-0-linux-x64-installer.run

install to /opt/bitnami/

sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf

update document root

DocumentRoot "/opt/bitnami/apache2/htdocs"
  <Directory "/opt/bitnami/apache2/htdocs">

to

 DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
  <Directory "/opt/bitnami/apps/wordpress/htdocs">

then lower under ssl

<VirtualHost _default_:443>
  DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"  #Edit
  SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/server.key"

  <Directory "/opt/bitnami/apps/wordpress/htdocs"> #Edit

...

at the end add the following to allow for larger PHP uploads. Adjust so your All-in-One WordPress Backup file will upload.

php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300

sudo nano /opt/bitnami/apps/wordpress/htdocs/wp-config.php

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');

to

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST]);
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);

sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf

#Include "/opt/bitnami/apps/wordpress/conf/httpd-prefix.conf"  

sudo /opt/bitnami/ctlscript.sh restart apache

go ahead and enter ip address in browser

Update WordPress and plugins

Before using all-in-one wp migration change the a record to the new ip address and set up encryption.

https://docs.bitnami.com/aws/how-to/generate-install-lets-encrypt-ssl/

Install Let’s Encrypt

For bitnami v5.9.1 just run

sudo /opt/bitnami/bncert-tool

For older versions, you’ll have to install the tool first

wget -O bncert-linux-x64.run https://downloads.bitnami.com/files/bncert/latest/bncert-linux-x64.run
sudo mkdir /opt/bitnami/bncert
sudo mv bncert-linux-x64.run /opt/bitnami/bncert/
sudo chmod +x /opt/bitnami/bncert/bncert-linux-x64.run
sudo ln -s /opt/bitnami/bncert/bncert-linux-x64.run /opt/bitnami/bncert-tool

now you can run the Bitnami HTTPS Configuration Tool

sudo /opt/bitnami/bncert-tool

Remove Bitnami Banner

sudo /opt/bitnami/apache2/bnconfig --disable_banner 1

Reverse Order Numbering in Microsoft Word

  1. Select Paragraphs
  2. Under insert, click Table, then Convert Text To Table…
  3. Number of Columns: 1
  4. Separate Text at: Paragraph
  5. Click Ok
  6. Right-click on table -> Insert -> Columns to the Left
  7. Shrink column size by dragging middle boundary toward left
  8. With ONLY left column selected, under Home, click Numbering (numbered list)
  9. Copy all numbers
  10. Open new document, and Paste as “Keep Text Only”
  11. Under Home, click Sort (a -z with an arrow)
  12. Sort by: Paragraphs, Descending
  13. Click ok
  14. Copy Text
  15. In original document, with original numbers selected, under Home, click Numbering(number list) to turn off numbering
  16. Ctrl-v or paste your sorted list of numbers.
  17. Format table by right clicking on table edge and selecting Table Properties

Thanks to Susan Harkins from techrepublic.com for the Original Post

Tapered Stream Lines from NHD Plus HR in ArcGIS Pro

Download NHDPlus HR Data

You can find the Data on the National Map:

https://apps.nationalmap.gov/downloader/

Zoom into the area you need data for, check Hydrography, NHDPlus High Resolution, then HU-4 Subregion (HUC 4 areas) unless you need a smaller area then HU-8.

Click the big blue button Search Products

Download the products you need. Choose the “Zip” version which is the GDB. If you get the z7 version you’ll download the Raster version.

Once downloaded, unzip, then drag the GDB folder to the database folder in the Catalogue panel.

Under Hydrography, drag NHDFlowline to your contents panel, then drag the NHDPlusFlowlineVAA table to contents as well.

On Contents panel, right click on NHDFlowline, under Joins and Relates, click Add Join.

for input Join Field, select NHDPlusID.
For Join Table, select NHDPlusFlowlineVAA then add NHDPlusID to the Join Table Field if it doesn’t auto populate.

Now that the polypath has the data we need, right click NHDFlowline in Contents panel and select Symbology to open its panel.

When I first started working with tapered streams, I would use “Mean Flow Volume,” but I’ve found using the TotalDrainageAreaSqKm creates better results especially for delta areas where rivers split.

In the Symbology panel, select TotalDrainageAreaSqKm then take a look at the Histogram

It looks like there are values in the -9999 (likely meaning a stream segment without information available), then a tiny percentage of streams with the largest area. To fix this, double click on NHDFlowline in Contents panel to open its properties. Select Definition Query, hit the +, and add a new query Where upstreamCumulativeAreaSqKm is greater than 0 AND UpstreamCumulativeAreaSqKm is less than 400.

Now when you pull up the Histogram in Symbology, it will present something much more meaningful.

Set Classes to 5, switch to Manual Interval, then adjust the Histogram breakpoints until it look right.

Now we’ve got to add back those major trunk rivers. Right click on NHDFlowline, click copy, then right click on the map name at the top (unless you renamed it it may be “Map”) select Paste. Rename this feature set by clicking on the words once. Change its name to NHDFlowlineBigRiver

Double click to enter its properties, select Definition Query. Then edit the definition Where TotalDrainageArea is greater or equal to 100 .

Go back to your Symbology panel, create 5 classes between 1.5 and 2pt, then change adjust values in histogram as needed.

Part 2 coming soon.

ArcGIS sketch to Lat Long

I’m sure there’s a better way to convert a sketch layer into coordinates, but this worked for me.

Use Geoprocessing tool: Layer to KML

Then use KML to Layer to import it back in with the coordinate system the map is in.

Open the features table, calculate:

New field: Lon

Lon = shapeToY(!Shape!)

Code Block:

def function(shape):
   point=shape.getPart(0)
   return point.Y

Repeat for the calculation for x

Data Sources

One of the most time-consuming parts of building maps is finding the data sets you want. I’m often forgetting where I found different datasets, and I wanted to share some of the ones I like to go back to.

USA Datasets

USGS National Map

https://apps.nationalmap.gov/viewer/

Mineral Resources Online Spatial Data:

https://mrdata.usgs.gov/general/map-us.html

Purdue’s GIS Data by State

A concise list of important resources available to you on the web and at Purdue. https://guides.lib.purdue.edu/c.php?g=353290&p=2378621

Convert DDMM.SS to Decimal Degrees

Quick tip if you get data coded with your lat long coded in Deg, Min, Sec

Open your table -> Calculate Field -> New Field = Lat
Field Type = Float
Lat = ConvertLat(!START_LAT__DDMM_MM_!)

def ConvertLat(lat):
    d = lat[-7:-5]
    m = lat[-5:-3]
    s = lat[-2:]
    return float(d) + float(m)/60 + (float(s)/(60*60))

Do the same thing for Long, keep in mind you may need to add a “-” to your calculation.

Field Name = Lon
Field Type = Float
Lon = ConvertLat(!START_LON__DDMM_MM_!)

def ConvertLat(lon):
    d = lon[-7:-5]
    m = lon[-5:-3]
    s = lon[-2:]
    return -(float(d) + float(m)/60 + (float(s)/(60*60)))

if your decimal is DD MM.MMM then you can use

def ConvertLat(lat):
    d = lat[:2]
    m = lat[3:8]
    return float(d) + float(m)/60

Don’t forget to add – if W or S

def ConvertLat(lon):
    d = lat[:2]
    m = lat[3:8]
    return -(float(d) + float(m)/60)

ArcGIS RemoteApp on mac from Windows Machine

Turns out you can use RemoteApp Tool to open a remote app on a windows machine on a mac. Here’s how I used it to run ArcGIS Pro to appear like it’s running on my mac.

Download RemoteApp Tool: http://www.kimknight.net/remoteapptool

Install it on your windows machine: (Even though it says it’s unsupported I installed it on a Windows 10 Pro machine)

  • Open RemoteApp Tool
  • Click +
  • Find whatever app you want (c:\program files\ArcGIS\bin\arcgispro.exe)
  • Create RDP File & Save to a shared drive on the mac.
  • In mac, open RDP file in Remote Desktop.

You may need to open the RDP file in a text editor to change the connection address.