Guide: Using FileZilla SFTP to Connect MacBook Air M1 to GCP Server
Guide: Using FileZilla SFTP to Connect MacBook Air M1 to a GCP Server
This guide explains how to generate an SSH key on your MacBook Air M1, add it to your Google Cloud instance, configure FileZilla for SFTP access, and handle common permission issues.
Step 1: Generate an SSH Key on MacBook Air
Open Terminal:
PressCommand + Space
, type Terminal, and pressEnter
.Generate the SSH key:
Run the following command (replace"your-email@example.com"
with your actual email):ssh-keygen -t rsa -b 4096 -C "your-email@example.com"
Follow the prompts:
- Press Enter to save the key to the default location (
~/.ssh/id_rsa
). - Optionally, enter a passphrase or press Enter for none.
- Press Enter to save the key to the default location (
Copy your public key:
Run the command below and copy the entire output:cat ~/.ssh/id_rsa.pub
Step 2: Add the SSH Key to Google Cloud
Log in to Google Cloud Console:
Navigate to Compute Engine → VM Instances.Select your instance:
Click on your instance name.Add the SSH key:
- Scroll down to the SSH Keys section.
- Click Edit → Add Item.
- Paste your public key (the one starting with
ssh-rsa
). - Click Save.
Step 3: Install FileZilla on Your MacBook
Download FileZilla:
Visit the official FileZilla website to download the application.Install and launch FileZilla.
Step 4: Configure FileZilla for SFTP
Open Site Manager:
In FileZilla, click File → Site Manager.Create a new site:
Click New Site and give it a name (e.g., "GCP Server").Enter the connection details:
- Protocol:
SFTP - SSH File Transfer Protocol
- Host: Your GCP instance's external IP (found in Compute Engine under "External IP")
- Port:
22
- Logon Type:
Key file
- User: Your GCP username (e.g.,
your-username
) - Key file: Click Browse, navigate to
~/.ssh/id_rsa
, and select it.
- Protocol:
Connect:
Click Connect to initiate the SFTP session.
Step 5: Adjust Permissions to Prevent "Permission Denied" Errors
If you encounter a "Permission Denied" error when transferring files:
Connect to your GCP instance via SSH:
ssh -i ~/.ssh/id_rsa your-username@your-external-ip
Change directory permissions:
Replace/path/to/directory
with the target directory on your server:chmod 777 /path/to/directory
Note: Setting permissions to
777
grants full read, write, and execute rights to everyone. Use it only when necessary and consider more secure alternatives for production environments.
Step 6: Transfer Files Using FileZilla
Interface Overview:
FileZilla displays two panels:- Left panel: Your local MacBook files.
- Right panel: Your GCP server files.
File Transfers:
- Upload files: Drag files from the left panel to the right panel.
- Download files: Drag files from the right panel to the left panel.
Step 7: Configure Firewall Rules (If Needed)
If you are unable to connect, ensure that the Google Cloud Firewall permits SFTP (port 22).
Access Firewall Rules:
In Google Cloud Console, go to VPC Network → Firewall Rules.Create a new firewall rule:
- Name:
allow-sftp
- Targets:
All instances in the network
- Source IP ranges:
0.0.0.0/0
- Protocols and ports:
TCP: 22
- Click Create.
- Name:
Step 8: (Optional) Add Your SSH Key to the SSH Agent
If FileZilla repeatedly asks for the SSH key, add it to your SSH agent to streamline the process:
Start the SSH agent:
eval "$(ssh-agent -s)"
Add your private key:
ssh-add ~/.ssh/id_rsa
🎉 Conclusion
You are now ready to manage your GCP server using FileZilla SFTP from your MacBook Air M1. Enjoy seamless file transfers!
If you have any questions or encounter issues, feel free to seek further assistance.
Comments
Post a Comment