A method of controlling an automatic teller machine to perform a data communication with a host, to receive, online from a shared key transmission apparatus, a shared key used for the data communication, and to install the received shared key, the method comprising:
- generating a random number and encrypting the random number to generate a first cryptogram;
- transmitting the first cryptogram to the shared key transmission apparatus;
- receiving, from the shared key transmission apparatus, a shared key that is encrypted using the random number restored from the first cryptogram;
- and
- restoring the shared key from the encrypted shared key using the generated random number.