Cygwin config

What is Cygwin

Cygwin is:-

  • a collection of tools which provide a Linux look and feel environment for Windows.
  • a DLL (cygwin1.dll) which acts as a Linux API layer providing substantial Linux API functionality.

What Cygwin isn't

Cygwin is not:-

  • a way to run native Linux apps on Windows. You must rebuild your application from source if you want it to run on Windows.
  • a way to magically make native Windows apps aware of UNIX® functionality like signals, ptys, etc. Again, you need to build your apps from source if you want to take advantage of Cygwin functionality.

Configuring Cygwin

Download cygwin.exe from http://cygwin.com/setup.exe and run it.

For installation on machines which don't have internet access, you can specify only to download and not install the files locally. However, you will need to have selected all the packages you will require in advance, cygwin will suggest the dependencies you will need to select additionally.

The cygwin directory can then be copied to the target machine and then run on the target without needing internet access. Specify use a local source for install files.

Configuring sshd

sshd seems a bit troublesome to configure, these instructions were generated from an install on w2k3 server.

From http://www.noah.org/ssh/cygwin-sshd.html

Install the following Cygwin packages (rerun setup if necessary -- you can add packages after you have already installed Cygwin).

    Admin --> cygrunsrv
    Net --> openssh

Open a new bash shell window and run the SSH configure stuff.

    ssh-host-config -y

This step will create necessary configuration files, a priviledge separation user and necessary directories.

Although it does not mention it, tcp_wrappers looks like a requirement, without it the ssh access won't work. However see below for configuring access to use it.

Create the passwd and group files with:-
  
mkpasswd -l > /etc/passwd
mkgroup -l > /etc/group  

You may need to run passwd <user> to set the unix password as the mkpasswd commands cannot read a windows password and the encryption for windows and unix passwords is different anyway.

Also edit /etc/hosts.allow, the default install seems to have the deny all before the allow for sshd:-

ALL : localhost 127.0.0.1/32 [::1]/128 [::ffff:127.0.0.1]/128 : allow
sshd: ALL : allow
ALL : PARANOID : deny

After this config change, you should be able to log in:-

[scope@mon01 ~]$ ssh -l user 172.27.20.23
The authenticity of host '172.27.20.23 (172.27.20.23)' can't be established.
RSA key fingerprint is 9a:ff:86:8d:c6:15:61:08:46:35:22:97:e0:a2:16:8b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.27.20.23' (RSA) to the list of known hosts.
user@172.27.20.23's password:
Could not chdir to home directory /home/user: No such file or directory
Copying skeleton files.
These files are for the users to personalise their cygwin experience.

They will never be overwritten nor automatically updated.

`./.bashrc' -> `/home/scope//.bashrc'
`./.bash_profile' -> `/home/scope//.bash_profile'
`./.inputrc' -> `/home/scope//.inputrc'
`./.profile' -> `/home/scope//.profile'

user@server02a ~
$ pwd
/home/user

Certificate based access

Passwordless access is possible just the same as to a unix server, process is as follows:-

  1. Create the user as a windows abuser. Add to windows groups as necessary, eg local admins.
  2. Run mkpasswd and group as above to create passwd and group files.
  3. Run passwd to set unix password for user.
  4. Log in remotely from the desired source system to accept fingerprint and check password access.
  5. Copy public key to /home/<user>/.ssh/authorized_keys.
  6. Test access from source system, no password should be prompted for.
[user@mon01 ~]$ ssh -l scope 172.27.20.23
Last login: Fri Sep 28 12:55:06 2012 from 172.27.20.21

user@werver02a ~
$ uname -a
CYGWIN_NT-5.2 server02a 1.7.16(0.262/5/3) 2012-07-20 22:55 i686 Cygwin

user@server02a ~
$
 
cygwin/config.txt · Last modified: 18/07/2019 15:33 by 127.0.0.1