Couple of thoughts here.
Call a locksmith and have them come to you and have them cut a key. There are books for them to cut the keys. The code you're thinking about is the keyless entry code and that's not the same as the code for the key.
Have a tow truck come out and do a dolly or flatbed tow to dealership. If you're too far out for this to be affordable and want to tow it yourself and don't mind getting under the truck, you can disconnect the driveshaft from the rear axle and the back of the transfer case. Then you can tow with the rear wheels on the ground and the front wheels on the tow dolly. Let us know what happens.