summaryrefslogtreecommitdiff
path: root/contrib/cygwin
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-01-19 05:37:32 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-01-19 05:37:32 +0000
commitb100ec95429daa986cb31834e462083adc22e8b6 (patch)
tree74ea3e32b28515b06a090880c7499113906a93aa /contrib/cygwin
parent22e22bf9bab94862c860ad4ed652f308dda63f81 (diff)
- (bal) Updated contrib/cygwin/ by Corinna Vinschen <vinschen@redhat.com>
Also removed some of the 'ISSUES' comments that have been verified by djm.
Diffstat (limited to 'contrib/cygwin')
-rw-r--r--contrib/cygwin/README35
-rw-r--r--[-rwxr-xr-x]contrib/cygwin/ssh-host-config (renamed from contrib/cygwin/ssh-config)168
-rw-r--r--contrib/cygwin/ssh-user-config200
3 files changed, 343 insertions, 60 deletions
diff --git a/contrib/cygwin/README b/contrib/cygwin/README
index 8c9d0bb73..ac0955836 100644
--- a/contrib/cygwin/README
+++ b/contrib/cygwin/README
@@ -20,18 +20,41 @@ of the files has changed from /usr/local to /usr. The global configuration
20files are in /etc now. 20files are in /etc now.
21 21
22If you are installing OpenSSH the first time, you can generate 22If you are installing OpenSSH the first time, you can generate
23global config files, server keys and your own user keys by running 23global config files and server keys by running
24 24
25 /usr/bin/ssh-config 25 /usr/bin/ssh-host-config
26 26
27If you are updating your installation you may run the above ssh-config 27Note that this binary archive doesn't contain default config files in /etc.
28That files are only created if ssh-host-config is started.
29
30If you are updating your installation you may run the above ssh-host-config
28as well to move your configuration files to the new location and to 31as well to move your configuration files to the new location and to
29erase the files at the old location. 32erase the files at the old location.
30 33
31Be sure to start the new ssh-config when updating! 34To support testing and unattended installation ssh-host-config got
35some options:
32 36
33Note that this binary archive doesn't contain default config files in /etc. 37usage: ssh-host-config [OPTION]...
34That files are only created if ssh-config is started. 38Options:
39 --debug -d Enable shell's debug output.
40 --yes -y Answer all questions with "yes" automatically.
41 --no -n Answer all questions with "no" automatically.
42
43You can create the private and public keys for a user now by running
44
45 /usr/bin/ssh-user-config
46
47under the users account.
48
49To support testing and unattended installation ssh-user-config got
50some options as well:
51
52usage: ssh-user-config [OPTION]...
53Options:
54 --debug -d Enable shell's debug output.
55 --yes -y Answer all questions with "yes" automatically.
56 --no -n Answer all questions with "no" automatically.
57 --passphrase -p word Use "word" as passphrase automatically.
35 58
36Install sshd as daemon via SRVANY.EXE (recommended on NT/W2K), via inetd 59Install sshd as daemon via SRVANY.EXE (recommended on NT/W2K), via inetd
37(results in very slow deamon startup!) or from the command line (recommended 60(results in very slow deamon startup!) or from the command line (recommended
diff --git a/contrib/cygwin/ssh-config b/contrib/cygwin/ssh-host-config
index 20c8cceb0..6fe2c7795 100755..100644
--- a/contrib/cygwin/ssh-config
+++ b/contrib/cygwin/ssh-host-config
@@ -1,11 +1,9 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# ssh-config, Copyright 2000, Red Hat Inc. 3# ssh-host-config, Copyright 2000, Red Hat Inc.
4# 4#
5# This file is part of the Cygwin port of OpenSSH. 5# This file is part of the Cygwin port of OpenSSH.
6 6
7# set -x
8
9# Subdirectory where the new package is being installed 7# Subdirectory where the new package is being installed
10PREFIX=/usr 8PREFIX=/usr
11 9
@@ -16,8 +14,19 @@ SYSCONFDIR=/etc
16OLDPREFIX=/usr/local 14OLDPREFIX=/usr/local
17OLDSYSCONFDIR=${OLDPREFIX}/etc 15OLDSYSCONFDIR=${OLDPREFIX}/etc
18 16
17progname=$0
18auto_answer=""
19
19request() 20request()
20{ 21{
22 if [ "${auto_answer}" = "yes" ]
23 then
24 return 0
25 elif [ "${auto_answer}" = "no" ]
26 then
27 return 1
28 fi
29
21 answer="" 30 answer=""
22 while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ] 31 while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ]
23 do 32 do
@@ -32,6 +41,48 @@ request()
32 fi 41 fi
33} 42}
34 43
44# Check options
45
46while :
47do
48 case $# in
49 0)
50 break
51 ;;
52 esac
53
54 option=$1
55 shift
56
57 case "$option" in
58 -d | --debug )
59 set -x
60 ;;
61
62 -y | --yes )
63 auto_answer=yes
64 ;;
65
66 -n | --no )
67 auto_answer=no
68 ;;
69
70 *)
71 echo "usage: ${progname} [OPTION]..."
72 echo
73 echo "This script creates an OpenSSH host configuration."
74 echo
75 echo "Options:"
76 echo " --debug -d Enable shell's debug output."
77 echo " --yes -y Answer all questions with \"yes\" automatically."
78 echo " --no -n Answer all questions with \"no\" automatically."
79 echo
80 exit 1
81 ;;
82
83 esac
84done
85
35# Check for running ssh/sshd processes first. Refuse to do anything while 86# Check for running ssh/sshd processes first. Refuse to do anything while
36# some ssh processes are still running 87# some ssh processes are still running
37 88
@@ -71,6 +122,7 @@ fi
71# Check for an old installation in ${OLDPREFIX} unless ${OLDPREFIX} isn't 122# Check for an old installation in ${OLDPREFIX} unless ${OLDPREFIX} isn't
72# the same as ${PREFIX} 123# the same as ${PREFIX}
73 124
125old_install=0
74if [ "${OLDPREFIX}" != "${PREFIX}" ] 126if [ "${OLDPREFIX}" != "${PREFIX}" ]
75then 127then
76 if [ -f "${OLDPREFIX}/sbin/sshd" ] 128 if [ -f "${OLDPREFIX}/sbin/sshd" ]
@@ -116,6 +168,7 @@ then
116 rm -f ${OLDPREFIX}/sbin/sshd.exe 168 rm -f ${OLDPREFIX}/sbin/sshd.exe
117 rm -f ${OLDPREFIX}/sbin/sftp-server.exe 169 rm -f ${OLDPREFIX}/sbin/sftp-server.exe
118 fi 170 fi
171 old_install=1
119 fi 172 fi
120fi 173fi
121 174
@@ -124,13 +177,19 @@ fi
124if [ ! -f "${SYSCONFDIR}/ssh_host_key" ] 177if [ ! -f "${SYSCONFDIR}/ssh_host_key" ]
125then 178then
126 echo "Generating ${SYSCONFDIR}/ssh_host_key" 179 echo "Generating ${SYSCONFDIR}/ssh_host_key"
127 ssh-keygen -f ${SYSCONFDIR}/ssh_host_key -N '' 180 ssh-keygen -t rsa1 -f ${SYSCONFDIR}/ssh_host_key -N '' > /dev/null
181fi
182
183if [ ! -f "${SYSCONFDIR}/ssh_host_rsa_key" ]
184then
185 echo "Generating ${SYSCONFDIR}/ssh_host_rsa_key"
186 ssh-keygen -t rsa -f ${SYSCONFDIR}/ssh_host_rsa_key -N '' > /dev/null
128fi 187fi
129 188
130if [ ! -f "${SYSCONFDIR}/ssh_host_dsa_key" ] 189if [ ! -f "${SYSCONFDIR}/ssh_host_dsa_key" ]
131then 190then
132 echo "Generating ${SYSCONFDIR}/ssh_host_dsa_key" 191 echo "Generating ${SYSCONFDIR}/ssh_host_dsa_key"
133 ssh-keygen -d -f ${SYSCONFDIR}/ssh_host_dsa_key -N '' 192 ssh-keygen -t dsa -f ${SYSCONFDIR}/ssh_host_dsa_key -N '' > /dev/null
134fi 193fi
135 194
136# Check if ssh_config exists. If yes, ask for overwriting 195# Check if ssh_config exists. If yes, ask for overwriting
@@ -151,7 +210,7 @@ fi
151 210
152if [ ! -f "${SYSCONFDIR}/ssh_config" ] 211if [ ! -f "${SYSCONFDIR}/ssh_config" ]
153then 212then
154 echo "Creating default ${SYSCONFDIR}/ssh_config file" 213 echo "Generating ${SYSCONFDIR}/ssh_config file"
155 cat > ${SYSCONFDIR}/ssh_config << EOF 214 cat > ${SYSCONFDIR}/ssh_config << EOF
156# This is ssh client systemwide configuration file. This file provides 215# This is ssh client systemwide configuration file. This file provides
157# defaults for users, and the values can be changed in per-user configuration 216# defaults for users, and the values can be changed in per-user configuration
@@ -179,7 +238,6 @@ then
179# BatchMode no 238# BatchMode no
180# CheckHostIP yes 239# CheckHostIP yes
181# StrictHostKeyChecking no 240# StrictHostKeyChecking no
182# IdentityFile ~/.ssh/identity
183# Port 22 241# Port 22
184# Protocol 2,1 242# Protocol 2,1
185# Cipher 3des 243# Cipher 3des
@@ -190,6 +248,11 @@ Host *
190 ForwardAgent no 248 ForwardAgent no
191 ForwardX11 no 249 ForwardX11 no
192 FallBackToRsh no 250 FallBackToRsh no
251
252# Try authentification with the following identities
253 IdentityFile ~/.ssh/identity
254 IdentityFile ~/.ssh/id_rsa
255 IdentityFile ~/.ssh/id_dsa
193EOF 256EOF
194fi 257fi
195 258
@@ -211,15 +274,20 @@ fi
211 274
212if [ ! -f "${SYSCONFDIR}/sshd_config" ] 275if [ ! -f "${SYSCONFDIR}/sshd_config" ]
213then 276then
214 echo "Creating default ${SYSCONFDIR}/sshd_config file" 277 echo "Generating ${SYSCONFDIR}/sshd_config file"
215 cat > ${SYSCONFDIR}/sshd_config << EOF 278 cat > ${SYSCONFDIR}/sshd_config << EOF
216# This is ssh server systemwide configuration file. 279# This is ssh server systemwide configuration file.
217 280
218Port 22 281Port 22
219#Protocol 2,1 282#
283Protocol 2,1
220ListenAddress 0.0.0.0 284ListenAddress 0.0.0.0
221#ListenAddress :: 285#ListenAddress ::
222#HostKey /etc/ssh_host_key 286#
287# Uncomment the following lines according to the used authentication
288HostKey /etc/ssh_host_key
289HostKey /etc/ssh_host_rsa_key
290HostKey /etc/ssh_host_dsa_key
223ServerKeyBits 768 291ServerKeyBits 768
224LoginGraceTime 600 292LoginGraceTime 600
225KeyRegenerationInterval 3600 293KeyRegenerationInterval 3600
@@ -262,63 +330,55 @@ UseLogin no
262EOF 330EOF
263fi 331fi
264 332
265# Ask user if user identity should be generated 333# Add port 22/tcp to services
266 334_sys="`uname -a`"
267if [ "X${HOME}" = "X" ] 335_nt=`expr "$_sys" : "CYGWIN_NT"`
268then 336if [ $_nt -gt 0 ]
269 echo '$HOME is nonexistant. Cannot create user identity files.'
270 exit 1
271fi
272
273if [ ! -d "${HOME}" ]
274then 337then
275 echo '$HOME is not a valid directory. Cannot create user identity files.' 338 _wservices="${SYSTEMROOT}\\system32\\drivers\\etc\\services"
276 exit 1 339 _wserv_tmp="${SYSTEMROOT}\\system32\\drivers\\etc\\srv.out.$$"
277fi 340else
278 341 _wservices="${WINDIR}\\SERVICES"
279# If HOME is the root dir, set HOME to empty string to avoid error messages 342 _wserv_tmp="${WINDIR}\\SERV.$$"
280# in subsequent parts of that script.
281if [ "X${HOME}" = "X/" ]
282then
283 HOME=''
284fi 343fi
344_services=`cygpath -u "${_wservices}"`
345_serv_tmp=`cygpath -u "${_wserv_tmp}"`
285 346
286if [ -e "${HOME}/.ssh" -a ! -d "${HOME}/.ssh" ] 347mount -b -f "${_wservices}" "${_services}"
287then 348mount -b -f "${_wserv_tmp}" "${_serv_tmp}"
288 echo '$HOME/.ssh is existant but not a directory. Cannot create user identity files.'
289 exit 1
290fi
291 349
292if [ ! -e "${HOME}/.ssh" ] 350if [ `grep -q 'sshd[ \t][ \t]*22' "${_services}"; echo $?` -ne 0 ]
293then 351then
294 mkdir "${HOME}/.ssh" 352 awk '{ if ( $2 ~ /^23\/tcp/ ) print "sshd 22/tcp #SSH daemon\r"; print $0; }' < "${_services}" > "${_serv_tmp}"
295 if [ ! -e "${HOME}/.ssh" ] 353 if [ -f "${_serv_tmp}" ]
296 then 354 then
297 echo "Creating users ${HOME}/.ssh directory failed" 355 if mv "${_serv_tmp}" "${_services}"
298 exit 1 356 then
357 echo "Added sshd to ${_services}"
358 else
359 echo "Adding sshd to ${_services} failed\!"
360 fi
361 rm -f "${_serv_tmp}"
362 else
363 echo "Adding sshd to ${_services} failed\!"
299 fi 364 fi
300fi 365fi
301 366
302if [ ! -f "${HOME}/.ssh/identity" ] 367umount "${_services}"
368umount "${_serv_tmp}"
369
370# Add sshd line to inetd.conf
371if [ -f /etc/inetd.conf ]
303then 372then
304 if request "Shall I create an RSA identity file for you?" 373 grep -q "^[# \t]*sshd" /etc/inetd.conf || echo "# sshd stream tcp nowait root /usr/sbin/sshd -i" >> /etc/inetd.conf
305 then
306 echo "Generating ${HOME}/.ssh/identity"
307 ssh-keygen -f "${HOME}/.ssh/identity"
308 fi
309fi 374fi
310 375
311if [ ! -f "${HOME}/.ssh/id_dsa" ] 376if [ "${old_install}" = "1" ]
312then 377then
313 if request "Shall I create an DSA identity file for you? (yes/no) " 378 echo
314 then 379 echo "Note: If you have used sshd as service or from inetd, don't forget to"
315 echo "Generating ${HOME}/.ssh/id_dsa" 380 echo " change the path to sshd.exe in the service entry or in inetd.conf."
316 ssh-keygen -d -f "${HOME}/.ssh/id_dsa"
317 fi
318fi 381fi
319 382
320echo 383echo
321echo "Note: If you have used sshd as service or from inetd, don't forget to" 384echo "Host configuration finished. Have fun!"
322echo " change the path to sshd.exe in the service entry or in inetd.conf."
323echo
324echo "Configuration finished. Have fun!"
diff --git a/contrib/cygwin/ssh-user-config b/contrib/cygwin/ssh-user-config
new file mode 100644
index 000000000..5a76adbaf
--- /dev/null
+++ b/contrib/cygwin/ssh-user-config
@@ -0,0 +1,200 @@
1#!/bin/sh
2#
3# ssh-user-config, Copyright 2000, Red Hat Inc.
4#
5# This file is part of the Cygwin port of OpenSSH.
6
7progname=$0
8auto_answer=""
9auto_passphrase="no"
10passphrase=""
11
12request()
13{
14 if [ "${auto_answer}" = "yes" ]
15 then
16 return 0
17 elif [ "${auto_answer}" = "no" ]
18 then
19 return 1
20 fi
21
22 answer=""
23 while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ]
24 do
25 echo -n "$1 (yes/no) "
26 read answer
27 done
28 if [ "X${answer}" = "Xyes" ]
29 then
30 return 0
31 else
32 return 1
33 fi
34}
35
36# Check options
37
38while :
39do
40 case $# in
41 0)
42 break
43 ;;
44 esac
45
46 option=$1
47 shift
48
49 case "$option" in
50 -d | --debug )
51 set -x
52 ;;
53
54 -y | --yes )
55 auto_answer=yes
56 ;;
57
58 -n | --no )
59 auto_answer=no
60 ;;
61
62 -p | --passphrase )
63 with_passphrase="yes"
64 passphrase=$1
65 shift
66 ;;
67
68 *)
69 echo "usage: ${progname} [OPTION]..."
70 echo
71 echo "This script creates an OpenSSH user configuration."
72 echo
73 echo "Options:"
74 echo " --debug -d Enable shell's debug output."
75 echo " --yes -y Answer all questions with \"yes\" automatically."
76 echo " --no -n Answer all questions with \"no\" automatically."
77 echo " --passphrase -p word Use \"word\" as passphrase automatically."
78 echo
79 exit 1
80 ;;
81
82 esac
83done
84
85# Ask user if user identity should be generated
86
87if [ ! -f /etc/passwd ]
88then
89 echo '/etc/passwd is nonexistant. Please generate an /etc/passwd file'
90 echo 'first using mkpasswd. Check if it contains an entry for you and'
91 echo 'please care for the home directory in your entry as well.'
92 exit 1
93fi
94
95uid=`id -u`
96pwdhome=`awk -F: '{ if ( $3 == '${uid}' ) print $6; }' < /etc/passwd`
97
98if [ "X${pwdhome}" = "X" ]
99then
100 echo 'There is no home directory set for you in /etc/passwd.'
101 echo 'Setting $HOME is not sufficient!'
102 exit 1
103fi
104
105if [ ! -d "${pwdhome}" ]
106then
107 echo "${pwdhome} is set in /etc/passwd as your home directory"
108 echo 'but it is not a valid directory. Cannot create user identity files.'
109 exit 1
110fi
111
112# If home is the root dir, set home to empty string to avoid error messages
113# in subsequent parts of that script.
114if [ "X${pwdhome}" = "X/" ]
115then
116 # But first raise a warning!
117 echo 'Your home directory in /etc/passwd is set to root (/). This is not recommended!'
118 if request "Would you like to proceed anyway?"
119 then
120 pwdhome=''
121 else
122 exit 1
123 fi
124fi
125
126if [ -e "${pwdhome}/.ssh" -a ! -d "${pwdhome}/.ssh" ]
127then
128 echo "${pwdhome}/.ssh is existant but not a directory. Cannot create user identity files."
129 exit 1
130fi
131
132if [ ! -e "${pwdhome}/.ssh" ]
133then
134 mkdir "${pwdhome}/.ssh"
135 if [ ! -e "${pwdhome}/.ssh" ]
136 then
137 echo "Creating users ${pwdhome}/.ssh directory failed"
138 exit 1
139 fi
140fi
141
142if [ ! -f "${pwdhome}/.ssh/identity" ]
143then
144 if request "Shall I create an SSH1 RSA identity file for you?"
145 then
146 echo "Generating ${pwdhome}/.ssh/identity"
147 if [ "${with_passphrase}" = "yes" ]
148 then
149 ssh-keygen -t rsa1 -N "${passphrase}" -f "${pwdhome}/.ssh/identity" > /dev/null
150 else
151 ssh-keygen -t rsa1 -f "${pwdhome}/.ssh/identity" > /dev/null
152 fi
153 if request "Do you want to use this identity to login to this machine?"
154 then
155 echo "Adding to ${pwdhome}/.ssh/authorized_keys"
156 cat "${pwdhome}/.ssh/identity.pub" >> "${pwdhome}/.ssh/authorized_keys"
157 fi
158 fi
159fi
160
161if [ ! -f "${pwdhome}/.ssh/id_rsa" ]
162then
163 if request "Shall I create an SSH2 RSA identity file for you? (yes/no) "
164 then
165 echo "Generating ${pwdhome}/.ssh/id_rsa"
166 if [ "${with_passphrase}" = "yes" ]
167 then
168 ssh-keygen -t rsa -N "${passphrase}" -f "${pwdhome}/.ssh/id_rsa" > /dev/null
169 else
170 ssh-keygen -t rsa -f "${pwdhome}/.ssh/id_rsa" > /dev/null
171 fi
172 if request "Do you want to use this identity to login to this machine?"
173 then
174 echo "Adding to ${pwdhome}/.ssh/authorized_keys2"
175 cat "${pwdhome}/.ssh/id_rsa.pub" >> "${pwdhome}/.ssh/authorized_keys2"
176 fi
177 fi
178fi
179
180if [ ! -f "${pwdhome}/.ssh/id_dsa" ]
181then
182 if request "Shall I create an SSH2 DSA identity file for you? (yes/no) "
183 then
184 echo "Generating ${pwdhome}/.ssh/id_dsa"
185 if [ "${with_passphrase}" = "yes" ]
186 then
187 ssh-keygen -t dsa -N "${passphrase}" -f "${pwdhome}/.ssh/id_dsa" > /dev/null
188 else
189 ssh-keygen -t dsa -f "${pwdhome}/.ssh/id_dsa" > /dev/null
190 fi
191 if request "Do you want to use this identity to login to this machine?"
192 then
193 echo "Adding to ${pwdhome}/.ssh/authorized_keys2"
194 cat "${pwdhome}/.ssh/id_dsa.pub" >> "${pwdhome}/.ssh/authorized_keys2"
195 fi
196 fi
197fi
198
199echo
200echo "Configuration finished. Have fun!"