Skip to main content

Access Virtual Machine (VM) using SSH Key (Windows / Macbook)

Here are step-by-step instructions to access a Server or Virtual Machine using SSH on both Windows and Mac:

Windows (Using PowerShell or Command Prompt)

  1. Ensure OpenSSH Client is Installed

    • Go to Settings > Apps > Optional Features.
    • Confirm OpenSSH Client is installed; if not, click Add a feature, find it, and install.
  2. Open PowerShell or Command Prompt

    • Press Windows + R, type powershell or cmd, and hit Enter.
  3. Connect via SSH

    • Use the command:
      ssh username@server_ip
      
    • Replace username with your remote server username.
    • Replace server_ip with the server’s domain name or IP address.
    • If the server uses a non-standard port, add -p followed by the port number:
      ssh username@server_ip -p port_number
      
  4. Verify and Accept Host Key

    • At first connection, you’ll be asked to verify the server’s fingerprint.
    • Type yes and press Enter to continue.
  5. Authenticate

    • Enter your password when prompted (or if using key authentication, make sure your private key is loaded or specify it with -i).
  6. You are connected when your prompt changes to the remote server’s shell.

Mac (Using Terminal)

  1. Open Terminal

    • Use Spotlight or find Terminal in Applications > Utilities.
  2. Connect via SSH

    • Type the command:
      ssh username@server_ip
      
    • Substitute username and server_ip with appropriate remote account and server info.
    • For custom ports, add -p option:
      ssh username@server_ip -p port_number
      
  3. Accept Host Key

    • For the first-time connection, review and accept the host key by typing yes.
  4. Authenticate

    • Enter your password or ensure your SSH private key is loaded (use ssh-add if needed).
  5. You are connected once you see the shell prompt of the remote server.

Additional Tips:

  • To specify a custom private key file, use the -i flag:
    ssh -i /path/to/private_key username@server_ip
    
  • To exit the SSH session, type:
    exit