Ultimate Cygwin Setup Guide (Part 1)

This is Part 1 of the two-part Ultimate Cygwin Setup Guide.


Install
Open File Explorer and create the directory C:\cygwin64 (or C:\cygwin if you are running 32-bit).

Visit cygwin.com in a web browser and select the “Install Cygwin” menu option on the upper left, then download setup-x86_64.exe (or setup.exe if you are running 32-bit) to C:\cygwin64

Navitate to C:\cygwin64 in File Explorer and run setup-x86_64.exe and install the following extra packages:

(Note: these instructions include installing the Apache web server with PHP. If you do not want to run the Apache web server and PHP then leave out the Apache packages below.)

astyle – use to cleaning/prettify C, C++, and Java source code
binutils – the main reason I install this is for the strings command
units – extremely useful command-line unit conversion program
bind-utils – provides nslookup, host, and dig commands
imagemagick – extremely powerful image manipulation/conversion app that includes the convert and mogrify commands
less – essential core command-line tool for displaying/reading text files
nc – netcat, very useful for network administration
rsync – arguably the most powerful remote file copy utility
openssh – essential core utility to enable incoming remote console sessions (sshd) and to connect to remote systems (ssh)
vim – essential core text-editor
wget – essential core command line utility for downloading files from the Internet
whois – command line tool to provide lookup of domain name registration and ownership info
screen – essential core tool which allows persistent console sessions which can be attached and detached from, also enables remote collaboration between multiple users
perl – essential core powerful scripting language, especially useful for string manipulation (matching and substitution)
python3 – essential core scripting language
ncftp – command line ftp client
ipcalc – extremely useful command line utility to provide detailed information about networks
dos2unix – essential utility to convert DOS-format files to Unix-format
chere – utility to create “Cygwin prompt here” context menu option in File Explorer
zip, unzip – essential core command line archival utilities
pwgen – extremely useful command-line password generator (try pwgen -ay -n14)
findutils – provides essential core utilities updatedb, locate, find, and xargs
inetutils – provides telnet (and also talk which was an early precursor to modern messaging apps and is still cool)
mysql-server, mysql – MySQL client and server
procps-ng – provides essential utilities ps, w, vmstat, free, and others (try ps -W)
sqlite3 – very cool, lightweight SQL database
source-highlight – very useful source code syntax highlighting that can be integrated with less
syslog-ng – provides a logging facility
httpd, httpd-mod_php7, libapr1-devel, libaprutil1-devel – OPTIONAL installing this will install Apache web server and PHP

Install Console
Visit the Console page on Sourceforge and click on the “files” tab, then “console-devel”, then “2.00” (or later version if there’s one available), then download Console-2.00b148-Beta_64bit.zip (or later version if available) (or Console-2.00b148-Beta_32bit.zip for 32-bit system) to your Downloads folder.

Make sure you have 7Zip installed then right-click on Console-2.00b148-Beta_64bit.zip in File Explorer and select context menu option “Extract to Console-2.00b148-Beta_64bit”.

Navigate into Console-2.00b148-Beta_64bit and move the folder Console2 to C:\Program Files

Navigate into C:\Program Files\Console2 and right-click Console.exe and select context menu option to create shortcut on Desktop.

Open Console and go to Settings. Under “Tabs” click “Add” and for Title: enter BASH. For Shell: enter C:\cygwin64\bin\bash.exe --login -i
For Startup dir enter C:\Users\user (whatever your user dir is).
Make sure the “Save settings to user directory” is checked, click OK and exit out of Console.

Initial Setup
Change home directory from C:\cygwin64\home\user to C:\Users\user (your actual Windows home directory which is far more logical):
edit /etc/nsswitch.conf (use either vim in a Cygwin console or use Notepad+)
add the following line at the bottom:
db_home: windows cygwin desc

Setup ssh and sshd
Open Console and run ssh-keygen -t rsa (or -t ecdsa if you want). Just hit enter at every prompt. It will ask for a password. Just leave blank and hit enter (this is not a login password so don’t worry).

Right-click on Console and select context menu item “Run as Administrator”. Type ssh-host-config and press enter. Answer the following:
Query: Should StrictModes be used? (yes/no) yes
Query: Should privilege separation be used? (yes/no) yes
Query: new local account ‘sshd’? (yes/no) yes
Query: Do you want to install sshd as a service? (yes/no) yes
Query: Enter the value of CYGWIN for the daemon: [] ntsec
Query: Do you want to use a different name? (yes/no) no
Query: Create new privileged user account ‘CIRCLE\cyg_server’ (Cygwin name: ‘cyg_server’)? (yes/no) yes password:

At this point, for the password, open another Console terminal and enter pwgen -ay -n 14 to generate some nice, complex passwords. Left click and drag the mouse cursor over one of the passwords which should highlight it, then release. This should copy it into the buffer.

Now open another Console terminal and middle-click in it. It should paste the password that was just copied into the buffer. If not, fix this copy/paste issue or just manually type in a complex password for the ssh-host-config prompt above, then press enter. That should finish the configuration of the SSH server (daemon).

Click the Windows key and type firewall and open Windows Firewall. Choose Advanced option and then for Inbound rules create new rule. Choose “Program” and browse to C:\cygwin64\sbin\sshd.exe and select it. For name of the rule use SSHD.

Now in the same Console that was used to run ssh-host-config start the SSH daemon with the command cygrunsrv.exe -S sshd. It should start without any error message.


Part 2 will be forthcoming soon! Please check back.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *