I have generated an identity in the browser, how can I import this identity into DFX through the pem file for use?

After the .pem file is generated by identity in the browser, can it be imported into dfx for use? Or create a new identity in dfx, how to import it into the browser for use? Is there any way to achieve this? this is important to me.

Keys should not be copied from one device to another. In general, you should instead add other devices’ principals as trusted users to your identities/canisters.

AFAIK, linking a dfx identity to II is not possible as a general authorization. What are you trying to do specifically?

Hi Severin, I am having a question along these lines as well.
My identity (created with dfx) has a principal and also wallet with cycles. I have exported the private key into a pem file.
My purpose is to setup the same identity/principal/wallet in another development computer, so that I can use the cycles in the new computer.
However, after identity import (on a fresh computer after installing dfx), I can’t get the wallet to show balance.
What should be the correct way to do this?

The wallet is not saved as part of the pem file. You have to transfer that one by hand, too. dfx identity --network ic set-wallet <wallet id> should do the trick

Thank you! Managed to get it working!

For anyone else who need to know the steps,
At the old computer

  1. get the pem file
  2. dfx identity --network ic get-wallet (to get the wallet id)

Then at the new computer

  1. dfx identity import <pem_file-name>
  2. dfx identity use
  3. dfx identity --network ic set-wallet
3 Likes