34 lines
1.0 KiB
Plaintext
34 lines
1.0 KiB
Plaintext
|
version: 0.2
|
||
|
type: update
|
||
|
description: An addon to add new SSH users.
|
||
|
name: Add SSH User
|
||
|
|
||
|
targetNodes:
|
||
|
nodeGroup: cp
|
||
|
|
||
|
globals:
|
||
|
username: "user${fn.random(10000,99999)}"
|
||
|
password: ${fn.password(min)}
|
||
|
sshHost: ${env.domain}
|
||
|
sshPort: 22
|
||
|
|
||
|
onInstall:
|
||
|
- cmd [cp]:
|
||
|
user: root
|
||
|
commands:
|
||
|
- useradd -m -s /bin/bash ${globals.username}
|
||
|
- echo "${globals.username}:${globals.password}" | chpasswd
|
||
|
- mkdir -p /home/${globals.username}/.ssh
|
||
|
- chmod 700 /home/${globals.username}/.ssh
|
||
|
- touch /home/${globals.username}/.ssh/authorized_keys
|
||
|
- chmod 600 /home/${globals.username}/.ssh/authorized_keys
|
||
|
- chown -R ${globals.username}:${globals.username} /home/${globals.username}/.ssh
|
||
|
- return:
|
||
|
type: info
|
||
|
message: "SSH account created successfully.\n\nSSH Host: ${globals.sshHost}\n\nPort: ${globals.sshPort}\n\nLogin Credentials\n\nUsername: ${globals.username}\n\nPassword: ${globals.password}"
|
||
|
|
||
|
responses:
|
||
|
installSuccess:
|
||
|
type: success
|
||
|
message: "SSH account created successfully."
|