如何让异地伙伴通过FileZilla访问我的Ubuntu服务器?
Absolutely you can set this up for your collaborator—here's a step-by-step guide tailored to your Ubuntu server setup that aligns with how you’re already using FileZilla over SSH:
1. Create a dedicated user account for your collaborator
- Log into your Ubuntu server via SSH (you can use your existing FileZilla SSH connection or a terminal).
- Run the command:
sudo adduser collaborator(replace "collaborator" with a username of your choice). - Follow the prompts to set a password, fill in optional user details, and confirm the account creation.
2. Configure SSH access for the new user
By default, Ubuntu’s SSH server allows password-based login for new users, but key-based authentication is far more secure—here’s how to set up both options:
Option A: Password-based access (quick but less secure)
- Ensure password login is enabled in the SSH config:
- Open the SSH config file:
sudo nano /etc/ssh/sshd_config - Locate the line
PasswordAuthenticationand set it toyes(remove the#if it’s commented out). - Save and exit (press Ctrl+O, hit Enter, then Ctrl+X), then restart SSH:
sudo systemctl restart sshd
- Open the SSH config file:
Option B: Key-based access (recommended for security)
- Ask your collaborator to generate an SSH key pair on their local machine: In FileZilla, they can go to
Edit > Settings > SFTP > Add key file, or use thessh-keygencommand in their terminal. - Have them send you their public key file (it ends with
.pub). - On your server, create the
.sshdirectory for the new user:sudo mkdir /home/collaborator/.ssh - Set secure permissions for the directory:
sudo chmod 700 /home/collaborator/.ssh - Append their public key to the authorized keys file:
sudo nano /home/collaborator/.ssh/authorized_keys(paste the key content here, then save and exit). - Fix permissions for the authorized keys file:
sudo chmod 600 /home/collaborator/.ssh/authorized_keys - Assign ownership to the new user:
sudo chown -R collaborator:collaborator /home/collaborator/.ssh - (Optional) For extra security, disable password login: Edit
sshd_configagain, setPasswordAuthentication no, then restart SSH.
3. Set up FileZilla for your collaborator
Tell your collaborator to configure their FileZilla with these settings:
- Host: Your server’s public IP address or domain name
- Protocol: Select
SFTP - SSH File Transfer Protocol - Logon Type:
- If using password access: Choose
Normal, then enter the username and password you created. - If using key-based access: Choose
Key file, enter the username, then browse to their private key file.
- If using password access: Choose
- Port: Leave as
22(the default SSH port—use your custom port if you changed it on the server).
4. Optional: Restrict access to your website directory only
To prevent the collaborator from browsing the entire server, you can set up a "chroot jail" to limit them to your website’s root folder (e.g., /var/www/html):
- Edit the SSH config file:
sudo nano /etc/ssh/sshd_config - Add these lines at the end (replace paths and username as needed):
Match User collaborator ChrootDirectory /var/www ForceCommand internal-sftp AllowTcpForwarding no X11Forwarding no - Ensure the chroot directory is owned by root:
sudo chown root:root /var/www - Restart SSH:
sudo systemctl restart sshd - Note: The collaborator will only be able to edit files in subdirectories they have write permissions for—use
sudo chown -R collaborator:www-data /var/www/htmlto grant them access to your website files.
内容的提问来源于stack exchange,提问作者Bryn
相关产品推荐
相关产品推荐

