Comfort has become a requirement in our modern world. This level of comfort, particularly in automobiles, can only be accomplished by outfitting the vehicle with additional electrical equipment. Some electronic equipment must communicate with one another, which necessitates the use of a data transmission. Nowadays, it is challenging to sell a new automobile that includes traditional keys. Now, a sophisticated remote locking system is used to lock and unlock autonomous vehicles (AV). A remote unlocking system consists of a transponder that wirelessly connects with the automobile transmitter to lock/unlock the automobile. Unfortunately, wireless communication methods of the internet of vehicle (IoV) face a number of threats. This study provides a safe solution for the automobile unlocking system that uses dynamically generated temporary keys to meet the future demands of smart cars driven by the Internet of Things. To maintain security, machine learning (ML) and physical unclonable function (PUF) are used to permit auto locking and unlocking capability in this work. The technique has exhibited 99.91\% accuracy, which proves the reliability of securing the automobile unlocking system. Moreover, the computation cost is 3.8 ms and communication overhead is 176 bytes for unlocking by the owner and 144 bytes when the car will be unlocked by other than the owner. Furthermore, both formal (Burrows–Abadi–Needham (BAN) logic) and informal security analysis of the proposed method are provided.