Check if SSH is Enabled For Users (Bulk Management)

kayvanaarssen

Verified User
Joined
Jun 26, 2015
Messages
10
Does anyone know how to check in bulk if a user on the system has SSH enabled or not.
And then as a bulk action enable SSH for users in bulk or disable it again.
Yes, we can enable/disable via GUI but for many users that's a pain.
Looking for a CLI way.
 
Looking for something like this?
perl -pi -e 's/ssh=ON/ssh=OFF/' /usr/local/directadmin/data/users/*/user.conf
and after that:
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
just to be sure, might not be required in this case.

Use at own risk. Be sure the "ssh for users" option is also off in reseller packages.
 
Looking for something like this?
perl -pi -e 's/ssh=ON/ssh=OFF/' /usr/local/directadmin/data/users/*/user.conf
and after that:
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
just to be sure, might not be required in this case.

Use at own risk. Be sure the "ssh for users" option is also off in reseller packages.
Sure, that's why we want to make sure its off for all of the users. And enable in bulk if needed. Some other way to do this in a way with an input file of the usernames
 
You asked in bulk, this is for all users, so bulk. I don't know why you want to put in user names, unless you want to exclude some.

Unfortunately this example will include admin so that has to be set back again.

Which can be easily done by the same thing but then the other way around with the username in it so like:
perl -pi -e 's/ssh=OFF/ssh=ON/' /usr/local/directadmin/data/users/admin/user.conf

I don't know a way how you can do this only for specific users, but you could create a script for it, something like:

Code:
#!/bin/bash
#Disable for SSH for all users:
perl -pi -e 's/ssh=ON/ssh=OFF/' /usr/local/directadmin/data/users/*/user.conf

#Enable again for certain users:
perl -pi -e 's/ssh=OFF/ssh=ON/' /usr/local/directadmin/data/users/admin/user.conf
perl -pi -e 's/ssh=OFF/ssh=ON/' /usr/local/directadmin/data/users/john/user.conf
perl -pi -e 's/ssh=OFF/ssh=ON/' /usr/local/directadmin/data/users/foo/user.conf
perl -pi -e 's/ssh=OFF/ssh=ON/' /usr/local/directadmin/data/users/peter/user.conf

#rewrite stuff:
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue

I'm no script write so I'm not 100% sure this is scriptwise correct, but it will work.
 
Back
Top