Salesforce CLI
Jitendra's Blog
SALESFORCE CLI GUIDE

Moving Authenticated Orgs in Salesforce CLI from One MacBook to Another

Securely migrate your CLI-authenticated Salesforce orgs without re-authenticating every sandbox, DevHub, and production environment.

sf
Current CLI Version
3
Simple Steps
100%
Local & Secure
No
Third-Party Tools

1 The Problem

Article Updated: February 2026

This article has been refreshed with the latest Salesforce CLI information. Note: The legacy sfdx commands are now deprecated; use sf commands instead. Originally published September 2024.

When setting up a new machine, one of the most common pain points for Salesforce developers and architects is migrating authenticated orgs. You don't want to re-authenticate every org manually—especially if you have dozens of sandboxes, DevHubs, and production environments already linked in your CLI.

Salesforce CLI stores authenticated org credentials locally. When you switch machines, these don't automatically carry over.

The challenge is:

2 The Solution

The solution is to export authentication URLs from the old laptop and then import them into the new one. Salesforce CLI provides an sfdxAuthUrl string that encodes your login session. By storing these in local files, you can move them safely to your new machine.

CLI Version Note: As of November 2024, the legacy sfdx commands are deprecated. This guide uses the current sf CLI commands, which are the officially supported version. The old sfdx commands still work but should be migrated to sf equivalents.

3 Step 1: Export Authenticated Orgs from Old MacBook

On your old laptop, run this script to extract all non-scratch orgs and save their sfdxAuthUrl values into individual files:

#!/bin/bash

# Create export directory
EXPORT_DIR=~/sfdx_auth_export
mkdir -p "$EXPORT_DIR"

# First, generate the org list
sf org list --json > ~/org_list.json

# Extract aliases from the JSON (non-scratch orgs)
aliases=$(jq -r '.result.nonScratchOrgs[].alias // empty' ~/org_list.json)

for alias in $aliases; do
    if [ -n "$alias" ]; then
        # Get the SFDX Auth URL
        auth_url=$(sf org display --target-org "$alias" --verbose --json | jq -r '.result.sfdxAuthUrl // empty')

        if [ -n "$auth_url" ]; then
            # Save to file named after the alias
            echo "$auth_url" > "$EXPORT_DIR/${alias}.sfdxurl"
            echo "Exported $alias"
        else
            echo "Failed to export $alias (no auth URL - may be JWT authenticated)"
        fi
    fi
done

echo "Export complete. Files are in $EXPORT_DIR"
Important: The sfdxAuthUrl is only available for orgs authenticated with the web server flow (browser login). Orgs authenticated with JWT bearer flow will not have an auth URL in the output.

4 Step 2: Transfer Files Securely

Transfer the folder ~/sfdx_auth_export to your new MacBook using one of these secure methods:

1
AirDrop

Direct transfer between Macs - fast and secure

2
USB Drive

Physical transfer - no network exposure

3
Encrypted Archive

Create a password-protected zip for any transfer method

Security Warning: Do NOT upload these files to GitHub, cloud drives (Google Drive, Dropbox, iCloud), or send via email. Treat them like passwords—they contain refresh tokens that grant access to your Salesforce orgs.

5 Step 3: Import Orgs to New MacBook

On your new machine, run the following script to import each .sfdxurl file back into Salesforce CLI:

#!/bin/bash

EXPORT_DIR=~/sfdx_auth_export

for file in "$EXPORT_DIR"/*.sfdxurl; do
    if [ -f "$file" ]; then
        alias=$(basename "$file" .sfdxurl)

        # Import the URL with alias
        sf org login sfdx-url --sfdx-url-file "$file" --alias "$alias"

        echo "Imported $alias"
    fi
done

echo "Import complete. Run 'sf org list' to verify."

After running the script, verify your orgs are available:

# List all authenticated orgs
sf org list

# Test connection to a specific org
sf org display --target-org your-alias

6 Why This Method Is Secure

For teams, this approach also prevents risky practices like checking authentication files into version control.

Best Practice: After successful import, delete the exported .sfdxurl files from both machines. You can always re-export them if needed.

7 Frequently Asked Questions

Use sf org display --target-org <alias> --verbose --json to get the sfdxAuthUrl, then save it to a file. This URL contains encrypted credentials that can be imported on another machine using sf org login sfdx-url.
The sfdx-style commands were deprecated in April 2023, and official support ended in November 2024. While the commands still work, you should migrate to the new sf CLI commands. The commands in this guide use the current sf syntax.
No, the sfdxAuthUrl is only available for orgs authenticated with the web server flow (browser login). For JWT-authenticated orgs, you need to re-authenticate on the new machine using the same connected app and private key file.
Salesforce CLI stores encrypted authentication data locally. On macOS, credentials are stored in the system keychain, with CLI configuration files in ~/.sf (new CLI) or ~/.sfdx (legacy) directories.
The SFDX authorization URL follows this format: force://<clientId>:<clientSecret>:<refreshToken>@<instanceUrl>. It contains all the data needed to re-establish an authenticated session.

8 Related Reading

Continue your Salesforce CLI and DevOps learning journey with these related guides:

9 Abbreviations & Glossary

Key Terms

Reference guide for technical terms and abbreviations used in this article.

CLI - Command Line Interface
sf - Current Salesforce CLI executable
sfdx - Legacy Salesforce DX CLI (deprecated)
DevHub - Developer Hub org for scratch orgs
JWT - JSON Web Token authentication
sfdxAuthUrl - Encrypted auth string for org login
Link copied to clipboard!
Previous Post
Chrome Extension to Boost Productivity
Next Post
Salesforce CPQ – What The Future Holds When RLM is on Horizon
Archives by Year
2026 13 2025 16 2024 2 2023 9 2022 8 2021 4 2020 18 2019 16 2018 21 2017 34 2016 44 2015 54 2014 30 2013 31 2012 46 2011 114 2010 162
Search Blog

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading