You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让异地伙伴通过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:
    1. Open the SSH config file: sudo nano /etc/ssh/sshd_config
    2. Locate the line PasswordAuthentication and set it to yes (remove the # if it’s commented out).
    3. Save and exit (press Ctrl+O, hit Enter, then Ctrl+X), then restart SSH: sudo systemctl restart sshd
  • 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 the ssh-keygen command in their terminal.
  • Have them send you their public key file (it ends with .pub).
  • On your server, create the .ssh directory 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_config again, set PasswordAuthentication 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.
  • 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/html to grant them access to your website files.

内容的提问来源于stack exchange,提问作者Bryn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:15:34