通过SSH以Plesk域名系统用户身份连接AWS Lightsail遇权限问题求助
Hey Robin, I know how frustrating it is to spend a whole day stuck on an SSH permission issue—let’s break this down and get you access to that /var/www/vhosts/domain.tld directory. The core problem here is that the directory is owned by Plesk’s domain-specific system user, not the ubuntu user you’ve been trying to use. Here’s what to do:
1. Identify the Correct Plesk System User
First, you need to use the system user that Plesk created for your domain, not ubuntu. To find this user:
- Log into your Plesk panel
- Navigate to your domain’s Hosting Settings
- Look for the System User field—this is the user that owns
/var/www/vhosts/domain.tld(it might look something likedomain_tldor a custom username you set)
2. Set Up SSH Keys for the Plesk System User
Your existing key pair was configured for the ubuntu user, so we need to add the public key to the Plesk user’s authorized keys:
Option A: If you can access the server as root
- SSH into the server as root first, then switch to the Plesk system user:
su - your_plesk_system_username - Create the
.sshdirectory (if it doesn’t exist) and set proper permissions:mkdir -p ~/.ssh chmod 700 ~/.ssh - Append your public key (from
key.pub) to theauthorized_keysfile:echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ..." >> ~/.ssh/authorized_keys - Lock down the permissions on
authorized_keys(critical for SSH to accept the key):chmod 600 ~/.ssh/authorized_keys
Option B: Use the Plesk Panel (no root access needed)
- In Plesk, go to System Users (under your domain or Tools & Settings)
- Edit the domain’s system user
- Scroll to the SSH Keys section, paste your public key content, and save
3. Connect with the Correct User
Now use the Plesk system user to initiate the SSH connection—replace the username with the one you found earlier:
ssh -i key.pem -T your_plesk_system_username@your_server_ip
Once connected, you’ll be in the user’s home directory, and you can easily navigate to /var/www/vhosts/domain.tld (you’ll have full access since this user owns it).
4. Troubleshoot If You Still Get Permission Denied
If you’re still seeing the error, check these common issues:
- Check SSH logs: Look at
/var/log/auth.logon the server—this will tell you exactly why the key was rejected (e.g., wrong permissions, invalid key format) - Verify SSH config: Ensure
/etc/ssh/sshd_confighasPubkeyAuthentication yesenabled (and no user-specific restrictions blocking key login) - Local key permissions: Double-check that your local
key.pemstill haschmod 600set—SSH will reject keys with overly open permissions
内容的提问来源于stack exchange,提问作者Robin Alexander

