ssh-user-config questions

1 view
Skip to first unread message

lpesc...@google.com

unread,
Feb 9, 2018, 5:06:33 PM2/9/18
to cygwin-users
Hi folks, new user here. 

I have a dilemma, and that is automating a ssh user config script. 
I use a shell script now, which is pasted below. I am setting up multiple machines using ansible. 
What is weird is it has to be run twice, as running it the first time does not start services Cygwin sshd nor rsync. The second time around does start those services but it causes Ansible not to be able to communicate with the windows machine, and I have not been able to figure out why.
Thus, options I'd like to know more about are:

1) Does anyone have a sh script that will do what I want it to, or
2) what files does ssh-user-config create? My thought is I can use ansible to copy those files over and then just run a simple script to start sshd and rsync.  I have done this successfully with other files like rsyncd.secrets. 

Thanks in advance!

Script I currently use. 

#!/bin/bash


#::Configure sshd service

if ! ssh-host-config --yes --pwd "PASSWORD"; then

    echo "ERROR: Failed to configure sshd"

    exit 1

fi

#echo db_home: /cygdrive/c/home/YRunner > C:\cygwin\etc\nsswitch.conf || exit /b 1


if ! net start sshd; then

    echo "ERROR: Failed to start sshd service."

        exit 1

fi


#configure the rsyncd service

cat <<EOF > /etc/rsyncd.conf

use chroot = yes


[yrunner_rsyncer]

#path = /cygdrive/c/home/YRunner

comment = YRunner Rsyncer

auth users = YRunner

secrets file = /etc/rsyncd.secrets

write only = false

read only = false

list = true

strict modes = false

hosts allow = *

EOF



/usr/bin/cygrunsrv.exe --install "rsyncd" --path /usr/bin/rsync --args "--daemon --no-detach" -f "Rsync daemon service"

if [[ "$?" -ne 0 ]]; then

    echo "ERROR: Failed to install rsyncd service"

    exit 1

fi


net start rsyncd


setx /M PATH "%PATH%;C:\Tools"









Reply all
Reply to author
Forward
0 new messages