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)
-
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.
-
Open PowerShell or Command Prompt
- Press
Windows + R, typepowershellorcmd, and hit Enter.
- Press
-
Connect via SSH
- Use the command:
ssh username@server_ip - Replace
usernamewith your remote server username. - Replace
server_ipwith the server’s domain name or IP address. - If the server uses a non-standard port, add
-pfollowed by the port number:ssh username@server_ip -p port_number
- Use the command:
-
Verify and Accept Host Key
- At first connection, you’ll be asked to verify the server’s fingerprint.
- Type
yesand press Enter to continue.
-
Authenticate
- Enter your password when prompted (or if using key authentication, make sure your private key is loaded or specify it with
-i).
- Enter your password when prompted (or if using key authentication, make sure your private key is loaded or specify it with
-
You are connected when your prompt changes to the remote server’s shell.
Mac (Using Terminal)
-
Open Terminal
- Use Spotlight or find Terminal in Applications > Utilities.
-
Connect via SSH
- Type the command:
ssh username@server_ip - Substitute
usernameandserver_ipwith appropriate remote account and server info. - For custom ports, add
-poption:ssh username@server_ip -p port_number
- Type the command:
-
Accept Host Key
- For the first-time connection, review and accept the host key by typing
yes.
- For the first-time connection, review and accept the host key by typing
-
Authenticate
- Enter your password or ensure your SSH private key is loaded (use
ssh-addif needed).
- Enter your password or ensure your SSH private key is loaded (use
-
You are connected once you see the shell prompt of the remote server.
Additional Tips:
- To specify a custom private key file, use the
-iflag:ssh -i /path/to/private_key username@server_ip - To exit the SSH session, type:
exit