Are you speaking of first boot setup? Or ssh keys? More details on specifically what you mean by “corrupt ssh identity” would be useful.
You may be interested in a script available in this post:
The “l4t_create_default_user” script can add an account name to the image being flashed, along with password. As a result the home directory would exist and login possible prior to ever flashing, although I’d be careful about that if you are sending this out with a “default” to end users. If the home directory content exists, and if you mean ssh keys, then this could be added before flash ever starts.
I personally use an overlay directory tree I created with some home content, including ssh keys, network setup, some GUI setup, so on. If I flash using that content, then I can ssh in even on first boot using keys. Since my tree is separate from the default image (though I copy it recursively into the default image) it tends to work even after release versions change (for example, ssh keys and user name do not need to change for different releases).
That particular script, even if you don’t use it, is worth examining since it is human readable. The script uses QEMU to operate on the default image as if the image were in a running system. This wouldn’t help on some edge cases where something fails, but it would make it possible to automate a lot of other customizations. This is not actually a “wrapper script” to
flash.sh as it merely gets installed once, and from then on generated images contain that information (wrappers to
flash.sh tend to run each time, whereas QEMU is used once on the
Linux_for_Tegra/rootfs/ content, which is inherited during a normal flash).
Hint: One can mount a loopback clone to replace “
Linux_for_Tegra/rootfs/”, it doesn’t have to be the default Ubuntu reference install. Note that if content is on your image before flash, then there is no need to add content from the running system. You could in fact use a clone of a fully updated system with all of your software on it. A loopback mounted clone can also work on a PC with QEMU if you want to go that far.