LochStudios  /  Help Centre  /  VPS & Linux  /  Connect to your VPS via SSH from macOS or Linux

Connect to your VPS via SSH from macOS or Linux

Connect to your VPS securely using SSH on macOS or Linux from the terminal.

Updated

SSH (Secure Shell) is built into macOS and Linux, so you can connect to your VPS directly from your terminal without installing extra software. The process is the same on both platforms.

Connect to Your VPS

1. Open a terminal
- On macOS: Press Cmd + Space, type "Terminal," and press Enter
- On Linux: Right-click your desktop and select "Open Terminal," or use your application menu

2. Connect via SSH
```bash
ssh youruser@your-server-ip
```
Replace youruser with your username (often root on a new VPS) and your-server-ip with your VPS's IP address.

3. Verify the host fingerprint
- On first connection, you'll see something like:
```
The authenticity of host '203.0.113.10 (203.0.113.10)' can't be established.
ECDSA key fingerprint is SHA256:ABC123...
Are you sure you want to continue connecting (yes/no/[fingerprint])?
```
- Type yes and press Enter to accept and save the fingerprint

4. Enter your password
- Type the password for that user and press Enter
- Note: the password won't display as you type—this is normal for security

You're now connected and can run commands on your VPS.

Save Your Connection (Optional)

To avoid typing the full command each time, you can add an alias to your shell config:

1. Edit your shell configuration file
- On macOS or Linux (using Bash or Zsh):
```bash
nano ~/.bashrc # or ~/.zshrc on macOS with Zsh
```

2. Add an alias at the end of the file
```bash
alias myvps="ssh youruser@your-server-ip"
```
Replace myvps with a short name you prefer.

3. Save and reload
- Press Ctrl + X, then Y, then Enter (in nano)
- Reload your shell config:
```bash
source ~/.bashrc # or source ~/.zshrc
```

Now you can connect by simply typing myvps.

Advanced: Passwordless SSH with Key Pairs

For better security and faster connections, use key-based authentication. See Secure SSH with key-based authentication and disable password login for full instructions.

Troubleshooting

"Connection refused" or "Connection timed out"
- Verify the IP address is correct
- Check that your hosting provider has assigned SSH access on port 22
- If your VPS is behind a firewall/security group, ensure port 22 is open

"Permission denied (publickey,password)"
- Confirm you're using the correct username and password
- Check for typos or extra spaces

"Host key verification failed"
- This may happen if the server's key changed
- Remove the old fingerprint and reconnect:
```bash
ssh-keygen -R your-server-ip
ssh youruser@your-server-ip
```

Slow connection
- SSH connections are typically instant; if slow, it may be a network issue
- Try a different network or contact your hosting provider

What's Next?

Once connected, you can run any command on your VPS. Common first steps:
- Update packages: sudo apt update && sudo apt upgrade (Debian/Ubuntu)
- Create a new user: sudo adduser newusername
- Check disk space: df -h
- View running processes: top


Was this article helpful?

← Back to VPS & Linux