A device sharing method, wherein the method is used by a first device to share a home device with a second device, a first application app is installed on the first device, the first app is logged in to by using a first account, and the method comprises: obtaining, by the first device, a first message leaving key, wherein the first message leaving key is used to encrypt an offline message between the first device and a first home device; obtaining, by the first device, a public key of the first home device, wherein the public key of the first home device is used to perform verification on an online message from the first home device; obtaining, by the first device, a second message leaving key and a public key of a second account, wherein the second message leaving key is used to encrypt an offline message between the first device and the second device, the second account is an account associated with the first app installed on the second device, and the public key of the second account is used to perform verification on an online message from the second device; obtaining, by the first device, a third message leaving key, wherein the third message leaving key is used to encrypt an offline message between the second device and the first home device; encrypting, by the first device, the public key of the second account and the third message leaving key by using the first message leaving key, to obtain first encrypted information, and requesting a server to push the first encrypted information to the first home device; and encrypting, by the first device, the public key of the first home device and the third message leaving key by using the second message leaving key, to obtain second encrypted information, and requesting the server to push the second encrypted information to the second device. obtaining, by the first device, a first message leaving key, wherein the first message leaving key is used to encrypt an offline message between the first device and a first home device; obtaining, by the first device, a public key of the first home device, wherein the public key of the first home device is used to perform verification on an online message from the first home device; obtaining, by the first device, a second message leaving key and a public key of a second account, wherein the second message leaving key is used to encrypt an offline message between the first device and the second device, the second account is an account associated with the first app installed on the second device, and the public key of the second account is used to perform verification on an online message from the second device; obtaining, by the first device, a third message leaving key, wherein the third message leaving key is used to encrypt an offline message between the second device and the first home device; encrypting, by the first device, the public key of the second account and the third message leaving key by using the first message leaving key, to obtain first encrypted information, and requesting a server to push the first encrypted information to the first home device; and encrypting, by the first device, the public key of the first home device and the third message leaving key by using the second message leaving key, to obtain second encrypted information, and requesting the server to push the second encrypted information to the second device. <EOS>