What is the OS X equivalent of "useradd -r -d /opt/otrs/ -c 'OTRS user' otrs" and "usermod -G nogroup otrs www-data" - linux

I am trying to install otrs on a mac. I am wondering what is the OS X equivalent of the following commands?
useradd -r -d /opt/otrs/ -c 'OTRS user' otrs
usermod -G nogroup otrs www-data

The following link might be helpful: http://www.maclife.com/article/columns/terminal_101_creating_new_users
And this script gives further information and examples: http://wiki.freegeek.org/index.php/Mac_OSX_adduser_script
According to that, the following commands should do it:
dscl . create /Users/otrs
dscl . create /Users/otrs RealName "OTRS user"
dscl . create /Users/otrs NFSHomeDirectory /opt/otrs
dseditgroup -o edit -t user -a otrs nogroup
dseditgroup -o edit -t user -a otrs otrs
dseditgroup -o edit -t user -a otrs www-data

Related

How to edit the mosquitto.conf in a mosquitto Docker container?

I have a linux system running with several Docker containers. One of them is mosquitto container which runs from mosquitto 1.6.7 docker image.
I do not have control how the Mosquitto container is created as it is given by default from a supplier/client.
I need to make changes in the mosquitto/config/mosquitto.conf file. This is the output when I run ls -l
/mosquitto/config # ls -l
total 4
-rwxrwxr-x 1 nobody nobody 210 May 24 05:35 mosquitto.conf
I tried the codes below to add a comment in the mosquitto.conf, but I am not successful.
/mosquitto/config # echo '#test' | su nobody -c 'tee -a mosquitto.conf'
nologin: this account is not available
/mosquitto/config # echo '#test' | su nobody -s sh -c 'tee -a mosquitto.conf'
su: can't execute 'sh': No such file or directory
/mosquitto/config # echo '#test' | su nobody -s bin/sh -c 'tee -a mosquitto.conf'
su: can't execute 'bin/sh': No such file or directory
/mosquitto/config # echo '#test' | su nobody -s /bin/sh -c 'tee -a mosquitto.conf'
tee: mosquitto.conf: Permission denied
#test
Is it possible to change the mosquitto.conf?
If yes, how? Thanks.
You don't.
You make a copy of it on the host machine, edit there and then mount that edited copy into the container when you start it.
e.g.
docker run -d -v /path/to/local/mosquitto.conf:/mosquitto/config/mosquitto.conf mosquitto

cygwin sshd service not starting

I used service account to install cygwin and sshd service. It was working fine till service account password was changed. Now, sshd service is not coming up.
$ net start sshd
System error 1069 has occurred.
The service did not start due to a logon failure.
Can somebody help and share the steps to fix it.
Likely a reset of needed privileges.
For that I use the following script:
$ cat bin/enable-cyg-server.sh
#!/bin/bash
# see
# /usr/share/csih/cygwin-service-installation-helper.sh
#
editrights -u cyg_server -a SeAssignPrimaryTokenPrivilege
editrights -u cyg_server -a SeCreateTokenPrivilege
editrights -u cyg_server -a SeTcbPrivilege
editrights -u cyg_server -a SeServiceLogonRight
editrights -u cyg_server -a SeIncreaseQuotaPrivilege
editrights -u sshd -a SeAssignPrimaryTokenPrivilege
editrights -u sshd -a SeCreateTokenPrivilege
editrights -u sshd -a SeTcbPrivilege
editrights -u sshd -a SeServiceLogonRight
editrights -u sshd -a SeIncreaseQuotaPrivilege

correct way to rename user and remove password with ec2 user-data

I have a centos7 base ami and have successfully changed the user name using the ec2-launch user data modified from an amazon-linux script
#!/bin/bash
groupadd ec2-user
usermod -d /home/ec2-user -m -g ec2-user -l ec2-user centos
echo "" | sudo tee -a /etc/sudoers
echo "Defaults:root !requiretty" | sudo tee -a /etc/sudoers
echo "ec2-user ALL=(ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers
echo "Defaults:ec2-user !requiretty" | sudo tee -a /etc/sudoers
log in works as expected and home directory has been changed, however when I use sudo it still asks for a password. As I cannot get into the file to check format I wonder if I am using the correct syntax?
How do change the user and remove the sudo password requirement in a single script?
I believe your Cloudinit userdata script is failing because it's attempting to use sudo without a tty (and the !requiretty hasn't been added yet). Since that script runs as root anyways, this should work:
#!/bin/bash
groupadd ec2-user
usermod -d /home/ec2-user -m -g ec2-user -l ec2-user centos
echo "" | tee -a /etc/sudoers
echo "Defaults:root !requiretty" | tee -a /etc/sudoers
echo "ec2-user ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers
echo "Defaults:ec2-user !requiretty" | tee -a /etc/sudoers

authentication for SSH into EC2 with new user failing

I am working with Chef on EC2 instances, and created a user data script to be passed in through the knife ec2 command, which creates a new user, copies the public key file from the default ec2-user and sets the correct ownership and permissions.
#!/bin/bash
CHEFUSER="$(date +%s | sha256sum | base64 | head -c 32)"
useradd $CHEFUSER
echo $CHEFUSER 'ALL=(ALL) NOPASSWD:ALL' | tee -a /etc/sudoers
cp -f /home/ec2-user/.ssh/authorized_keys /tmp/
chown $CHEFUSER /tmp/authorized_keys
runuser -l $CHEFUSER -c 'mkdir ~/.ssh/'
runuser -l $CHEFUSER -c 'mkdir ~/.aws/'
runuser -l $CHEFUSER -c 'chmod 700 ~/.ssh/'
runuser -l $CHEFUSER -c 'mv -f /tmp/authorized_keys ~/.ssh/'
runuser -l $CHEFUSER -c 'chmod 600 ~/.ssh/authorized_keys'
Checking ownership and permissions seems to return as expected after running the script:
# ls -l .ssh/authorized_keys
-rw-------. 1 NWYzMThiMDBmNzljOTgxZmU1NDE1ZmE0 root 396 May 29 11:28 .ssh/authorized_keys
# stat -c '%a %n' .ssh/
700 .ssh/
# stat -c '%a %n' .ssh/authorized_keys
600 .ssh/authorized_keys
If I SSH with the new user, the key is rejected. On a new instance, if I copy/paste the same commands as root in the terminal (which is how the script runs according to Amazon), everything works fine and I can then SSH in with the new user.

pastebinit how to post pasties with login info?

Not so many manuals for this package.
I want to post pasties to pastebin.com under my username. so
pastebinit -u myuser -p mypassword file.py
doesn't work, it's not logging in... why?
Try
$ pastebinit -u myuser -p mypassword -i file.py
Edit: Try a different host:
$ ./pastebinit -i file.py -b http://paste.ubuntu.com

Resources