OVH Community, your new community space.

post-installation script


crowarth
01-08-2013, 16:58
think i've got a basic script:

Code:
#!/bin/sh
passwd=blablabla
user="testpeon"
shell=/bin/bash

useradd -s $shell -m -p $passwd $user
i used 'mkpasswd' to generate the encrypted password for 'passwd=blablabla'. just need to sort out the ssh key, and hopefully that's achieved what i need.

crowarth
01-08-2013, 16:39
Quote Originally Posted by K.Kode
#!/bin/sh
passwd="$6$BLAHBLAHBLAH"
user="username"
useradd -m -p $passwd $user
mkdir /home/$user/.ssh
echo ssh-rsa BLAHBLAHBLAH= > /home/$user/.ssh/authorized_keys2


Or something of that ilk.
tried that, but it doesn't work

ok basically what i have right now is: (found this via google)

Code:
#!/bin/sh
user="testpeon"
shell=/bin/bash
OPENSSL=/usr/bin/openssl
PASS=`$OPENSSL rand -base64 12`
echo $PASS

useradd -s $shell -m -p $PASS $user
what i want to happen is for it to create a user (for example "bob") and set a pre-determined password for that user. then copy the ssh key into the correct place, for which i could use

Code:
echo ssh-rsa BLAHBLAHBLAH= > /home/$user/.ssh/authorized_keys2
from k.kodes example above. this would be the first part of my post-install script; the rest would be anything i would want to install etc ..

K.Kode
01-08-2013, 12:58
#!/bin/sh
passwd="$6$BLAHBLAHBLAH"
user="username"
useradd -m -p $passwd $user
mkdir /home/$user/.ssh
echo ssh-rsa BLAHBLAHBLAH= > /home/$user/.ssh/authorized_keys2


Or something of that ilk.

crowarth
01-08-2013, 12:44
hi guys,

i've become more interested in the re-installation templates as of late, and would like to make a template that includes a script to generate user accounts on a server, with the relevant ssh keys for that user.

is there a good resource that explains how to do this? i think for now i would be happy for it to auto create one user account and install the ssh key for that user (as i only use keypair login, rather than password)