- 1,041
- 429
Last edited:
I wanted to see whether Ansible can be used on DSM
Modifying the os and installing containers is a no brainer with Ansible. I thought maybe this might be a nice way to setup docker containers, reverse proxy configs and whatever the heart desires.
So far, I wrote a bash script that performs following actions:
- add an ansible user
- add an ansible goup
- add a file in /etc/sudoers.d/ that allows the user ansible to become root without entering a password
- create an rsa keypair for the ansible user
- copy the id_rsa.pub as ~/.ssh/authorized_keys for the ansible_user
- modify the sshd_conf to permit keyfile based authentification and restart sshd
- start an ansible docker container with playbooks, roles and inventory as bind-mount
Anyway, I must be doing something wrong with the sshd_conf, as no matter what I do, the ansible user is always asked for a password... as if the authorized_keys file is completly ignored...
I assume these are the relevant details:
I created a rsa-based keypair for a user:
copied id_rsa.pub to ~/.ssh/authorized_keys for the target user
changed permissions to 644 for authorized_keys and 600 for the .ssh folder.
Then I tried to enable Keyfile based auth:
And finaly restarted the sshd server:
WARNING: Running the last command will kill all active ssh connections (even the one you use to execute the command). Sometimes the sshd shell is not restarted properly, resulting in no connections beeing accepted. Though, repeating the command using telnet usualy does the trick and sshd starts to accept connections again.
Any Ideas on what I am missing?
So far, I wrote a bash script that performs following actions:
- add an ansible user
- add an ansible goup
- add a file in /etc/sudoers.d/ that allows the user ansible to become root without entering a password
- create an rsa keypair for the ansible user
- copy the id_rsa.pub as ~/.ssh/authorized_keys for the ansible_user
- modify the sshd_conf to permit keyfile based authentification and restart sshd
- start an ansible docker container with playbooks, roles and inventory as bind-mount
Anyway, I must be doing something wrong with the sshd_conf, as no matter what I do, the ansible user is always asked for a password... as if the authorized_keys file is completly ignored...
I assume these are the relevant details:
I created a rsa-based keypair for a user:
Code:
ssh-keygen -q -b 4096 -t rsa -N "" -f id_rsa
changed permissions to 644 for authorized_keys and 600 for the .ssh folder.
Then I tried to enable Keyfile based auth:
Code:
sudo sed -ie 's/^#PubkeyAuthentication/PubkeyAuthentication/g' /etc/ssh/sshd_config
sudo sed -ie 's/^#AuthorizedKeysFile/AuthorizedKeysFile/g' /etc/ssh/sshd_config
And finaly restarted the sshd server:
Code:
sudo synoservice --restart ssh-shell
Any Ideas on what I am missing?