Rundeck连接EC2节点SSH失败:默认用户为ec2-user而非root
Fixing Rundeck EC2 Node Plugin SSH Failure: Switching Default Username from ec2-user to root
I’ve dealt with this exact headache with the Rundeck EC2 Nodes Plugin before—let’s walk through how to fix the default username mapping so you can SSH into your EC2 nodes as root successfully:
Step 1: Confirm You’re Configuring the Right Source
First, double-check you’re editing the correct EC2 node source in your Rundeck project:
- Head to Project Settings > Nodes > Sources
- Locate your EC2 node source entry and click Edit
- Scroll down to the Mapping Params field—this is where we’ll override the default username.
Step 2: Apply the Correct Mapping Syntax
The key here is using the exact semicolon-separated syntax without extra spaces. Enter this in the Mapping Params field:
ssh-keypath.default=/path/to/your/private-key.pem;username.default=root
Important notes:
- Ensure the private key path is fully accessible by the Rundeck system user (typically
rundeckorroot). Set file permissions tochmod 600 /path/to/your/private-key.pemto avoid SSH permission errors. - Double-check that the private key is associated with your EC2 instance (the key pair you selected when launching the instance should match).
Step 3: Verify the Mapping Takes Effect
- Save your changes to the node source, then click Refresh Nodes to pull updated node data.
- Navigate to the Nodes tab in the Rundeck sidebar, select your EC2 node, and check the Username field—it should now display
rootinstead ofec2-user.
Troubleshooting If It Still Fails
If SSH is still failing after configuring the mapping, check these common issues:
- Root SSH access disabled on EC2: Some AMIs block root login by default. On your EC2 instance, edit
/etc/ssh/sshd_configto setPermitRootLogin yes, then restart the sshd service withsystemctl restart sshd. - Authorized keys missing: Ensure the public key from your private key pair is added to
/root/.ssh/authorized_keyson the EC2 instance. - Rundeck logs for clues: Check Rundeck’s log file (usually at
/var/log/rundeck/rundeck.log) for specific SSH error messages—this will help you spot if it’s a key permission issue, mapping not applying, or instance-level SSH restriction.
内容的提问来源于stack exchange,提问作者Milister
相关产品推荐
相关产品推荐

