How to open a scratch org created in another machine

sfdx force:org:list

The above command is specific to the machine you used. So don't think your office laptop has any knowledge of what orgs you authenticated with and set as the default hub org and the default scratch org.

You will need to authorize all the orgs you have with your office laptop again, and create your scratch org again from the office CLI.

Follow the below steps

1.Again authorize your scratch org using the sfdx force:auth:web:login and entering the username and password

2.Use force:config:set to set the default scratch org

sfdx force:config:set [email protected]

Optioanlly you can use sfdx force:alias:set to set alias as well default scratch org and the hub org .


Here are the commands I used to reconnect to a scratch org that was initiated on another machine. Please note, I had my .sfdx/ folder included in my git repo, so the org definition existed when I pulled my code down to my other machine.

It was not necessary to reauth to the scratch org in this case (which would be difficult since the password is not known).

shanekenyon@Shanes-MacBook-Pro ~/Documents/git/csvupload (master) $ sfdx force:config:set  defaultusername=dev
=== Set Config
NAME             VALUE
───────────────  ─────
defaultusername  dev
shanekenyon@Shanes-MacBook-Pro ~/Documents/git/csvupload (master) $ sfdx force:org:list
=== Orgs
  ALIAS      USERNAME                     ORG ID              CONNECTED STATUS
  ─────────  ───────────────────────────  ──────────────────  ────────────────
  devhub     [email protected]            ****000001Uj0****   Connected


     ALIAS  SCRATCH ORG NAME     USERNAME                       ORG ID              EXPIRATION DATE
───  ─────  ───────────────────  ─────────────────────────────  ──────────────────  ───────────────
(U)  dev    shanekenyon Company  [email protected]  ****000000982****   2018-10-23

If you used your own connected app to authenticate with the DevHub which was used to create the scratch org, then you can use that connected app to connect to any scratch org created using the same connected app.

You'll need the username, your connected app's private key and your client id (consumer key)

e.g.

sfdx force:auth:jwt:grant -u [email protected] -f server.key -i <ConsumerKey> -a <MyAlias> -r https://test.salesforce.com

Full documentation here under Authorize a Scratch Org