Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Tuesday, December 1, 2015

Working around Corrupted MAC on input. with Cygwin SSH

When connecting to some servers from Cygwin using ssh, the connection fails and I get this error:
Received disconnect from 1.2.3.4: 2: Corrupted MAC on input.

Looking at debug output, it seems like it is using "umac-64@openssh.com" as MAC algorithm. Forcing it to use something else works around the problem.

When using ssh directly, you can use this: (Other options should work as well, this one worked for me)
ssh -o 'MACs hmac-sha1-96' user@host
or
ssh -m hmac-sha1-96 user@host

When using rsync, you need to put one of the strings above in the --rsh parameter:
rsync --rsh="ssh -m hmac-sha1-96 user@host" :/remote-source /local-dest

A more permanent option is to add the setting to the ssh_config file. This is either /etc/ssh_config (affecting all users) or ~/.ssh/config.

A line using a modified set based on the defaults for my SSH version is:
MACs umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96

You can find the problematic MAC by running 
ssh -v user@host-that-disconnects-you 2>&1 | grep mac

Adding that as a line to ~/.ssh/config seems to be the easiest solution.

Saturday, February 2, 2008

Using SFU/SUA to replace Cygwin?

Microsoft's Services for Unix / Subsystem for Unix-based Applications (SUA) might make an excellent replacement for Cygwin.

Since SFU/SUA interacts directly with the Windows kernel, it should be several times faster than Cygwin. This might make SFU an excellent platform for the porting of *nix applications to Windows.

With a good package manager, SFU can be the Windows equivalent of Fink (which is an excellent product). It should be able to compile MOST *nix applications with a few minor modifications.

Several package managers have SFU/SUA ports underway, including Gentoo and Debian. An easy way to install those should dramatically increase their use as.

SUA one other major advantage above Cygwin: It is included with Windows 2003 R2 and Windows Vista (Enterprise and Utimate)

Friday, February 1, 2008

Running squid on Windows SBS 2003

I have a Windows Small Business Server 2003 Standard SP2 on my network and needed a proxy server in order to somewhat reduce the bandwidth usage.

I decided on squid, since it is free, well-supported and run on Windows. I decided on the SquidNT version, although the version available (free registration required for download) for Microsoft Services for Unix (or Subsystem for Unix Applications in newer Windows versions) should work as well.

SquidNT does not include an installer and is simply extracted to the hard drive (preferably to "c:\"). It requires a bit of configuration before starting. (Simply run "squid.exe" from the command-prompt to attempt to run it) The log file ("C:\squid\var\logs\cache.log") also provides help figuring out why squid would not start. You need to generate cache folders before squid would start. ("squid -z")

Once squid is running the configuration can be tweaked a bit further. (For basic configuration see here; for advanced tweaking see here).

Once configuration is complete, it is a good idea to install it as a service ("squid -i") and set it to start automatically from "Services" under Administrative tools.

For log file analysis I use SARG, combined with the sarg-reports script. (get my configured version here) Since sarg-reports is a unix shell script and expects to be run form a Unix-like environment, I recommend installing Microsoft Services for Unix (SFU). Once SFU is installed, install Interop Systems' package manager. After that, it might be a good idea to install a few packages, install at least bash and mktemp ("pkg_update -L bash" for bash). Certain SFU applications need DEP to be turned off (AlwaysOff mode). This might affect security negatively.

For SARG's installation, I recommend downloading its source code from sourceforge. Extract the source code with the following command: "tar -xzf sarg-2.2.3.1.tar.gz" (replace filename with correct version). Change into the correct directory and run "./configure" followed by "make" and "make install". Sarg's configuration file can be found in "/usr/local/sarg". Edit it to correctly reflect the paths of your log files and web server documents directory. (/dev/fs/C/inetpub/wwwroot for IIS) You might want to creat a symlink from /var/www/html as well (since sarg sometimes ignores its config file).

The next step would be to install sarg-reports and log rotation. Copy sarg-reports to /usr/local/bin (C:\SFU\usr\local\bin from a Windows POV). Make it executable (chmod +x /usr/local/bin/sarg-reports). Edit sarg-reports in a text editor (supporting unix text files, such as notepad2) and modify the first line to read "#!/usr/local/bin/bash". Set any other settings that you wish.

Sarg-reports needs the GNU coreutils version of date to run. Download and install coreutils from here. Copy date.exe, libiconv2.dll and libintl3.dll from "C:\Program Files\GnuWin32\bin" to c:\SFU\common (backup original first). Rename /bin/date and replace it with a symbolic link to /common/date.exe. Attempt to run sarg-reports to ensure that it returns no errors.

Now the cron entries need to be added. Run "crontab -e" and add the following: (followed by Ctrl-D) (all text might not show correctly at a low resolution and high zoom. View source to copy all text)
00 *      * * * /usr/local/bin/sarg-reports today
00 00 * * * /usr/local/bin/sarg-reports daily
00 01 * * 1 /usr/local/bin/sarg-reports weekly
30 02 1 * * /usr/local/bin/sarg-reports monthly && /dev/fs/C/squid/sbin/squid.exe -k rotate -n squid


Run "crontab -p" in order to save your password for use by cron.

SARG should run regularly now.