How to Set up Server Core for Windows Server 2008 to Be Managed Via SSH

How to Set up Server Core for Windows Server 2008 to Be Managed Via SSH

I wanted to setup a DNS and DHCP server for my home network. I could have used a Linux server to do this, but I wanted to write about server core. I also wanted to mess with working over ssh to do things, I found a SourceForge project that worked really well on 2008 x86, I had errors on 2008 R2 which I'll poke at next week.

I don't think I need to explain these things too much, I'll be using DNS and DHCP as they were intended to be used. I'm installing the SNMP service because I have setup a Zenoss server. It uses SNMP to monitor everything from disk usage to network usage. You will need to have your network card set to a static IP in the proper network for it work correctly.

PowerShell Installation

Windows 2008 Core

Install PowerShell following these instructions.

Windows 2008 R2 Core

Install PowerShell following these instructions.

Install OpenSSH

  • Download the install file
  • The installation takes care of everything but the firewall
  • Allow SSH through the firewall
    • netsh firewall set portopening TCP 22 "OpenSSH TCP22"

Basic Networking Configuration

netsh interface set interface name="Local Area Connection" newname="Public"

netsh interface ipv4 set address name="Public" static 192.168.1.1 255.255.255.0 192.168.1.254

netsh interface ipv4 set dnsserver name="Public" static 192.168.1.1 primary

netdom renamecomputer %computername% /newname:{newComputerName}

Installing the required services

DNS

start /w ocsetup DNS-Server-Core-Role

DHCP

start /w ocsetup DHCPServerCore

SNMP

start /w ocsetup SNMP-SC

Configuration of these services can be done via a server with RSAT installed, but that would be no fun at all, so we'll use the builtin tools to set things up. If you have read the above article you may already have SSH setup and be using puTTY or some other client to perform these tasks.

Configuring the required services

DNS: dnscmd

The following command creates a forward lookup zone and marks it as the primary zone on this server.

 dnscmd ServerName /ZoneAdd company.com /Primary /file company.com.dns

The following command creates a reverse lookup zone for 192.168.1.0/24 and marks it as the primary zone

dnscmd ServerName /ZoneAdd 1.168.192.in-addr.arpa /Primary /file 1.168.192.in-addr.arpa.dns

The following command creates an A record for the local server at 192.168.1.1

dnscmd ServerName /RecordAdd company.com @ A 192.168.1.1

The following command creates the reverse record for the server at 192.168.1.1

dnscmd ServerName /RecordAdd 1.168.192.in-addr.arpa 1 PTR company.com

Allow DNS traffic to pass through the firewall

netsh firewall set portopening TCP 53 "DNS-TCP"

netsh firewall set portopening UDP 53 "DNS-UDP"

DNSCMD Resources:

Setup DNS from the command-line

Configuring DNS on Server Core

DNSCMD Cheat Sheet

Administering DNS Server

DHCP: netsh

After installing the DHCP role on the core server you will need to run the following command to allow the service to auto-start

sc config dhcpserver start= auto

 

Original Content

Leave a Comment
  • Please add 8 and 6 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Richard Mueller edited Revision 6. Comment: Changed tag "Server Core for Windows Server 2008" to "Server Core". We already have tag "Windows Server 2008". Also removed tag "WS08"

  • Naomi  N edited Revision 4. Comment: Minor edit

  • Richard Mueller edited Revision 3. Comment: Modified title and tags

  • Jeffrey S. Patton edited Revision 2. Comment: Changed blog provider since this was published, updated to point to proper link.

Page 1 of 1 (4 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Jeffrey S. Patton edited Revision 2. Comment: Changed blog provider since this was published, updated to point to proper link.

  • this worked like a charm! :)

    It worked for 2012 Core also. But as u said 2008 R2 has some error, which you will post later.

    Please provide the link for the same.

  • Madhur,

    I'll see what I can dig up, I think it was something odd with the sourceforge ssh project.

  • Jeffrey,

    I did some digging and find out  that It does not create the service for SSHd. I created it manually but sc start  command fails.

    Moreover, this OpenSSH has limitations. If I try to execute pnputil, it says command not found. If it try to ftp to some machine, it does not print anything. Can you please suggest some good and robust CLI remote login tool??

  • I tried this.  It "sort of" works, until you need to use cmd.exe over a network connection and then it completely falls apart.  I tried cygwin/openssh.  It broke randomly.   I tried using OpenSSH.  Using CopSSH, I was able to log in and get a cmd.exe prompt:

    gist.github.com/.../6298756

    If you try to log in non-interactively, to run a simple command (or any command with quotes, really) cmd.exe barfs all over the double quotes.

    e.g.

    ssh user@172.16.125.225 echo "Task Scheduler"

    user@172.16.125.225's password:

    Task Scheduler

    ssh user@172.16.125.225 echo '"Task Scheduler"'

    user@172.16.125.225's password:

    "\"Task" "Scheduler\""

    FreeSSHd is dead.

    So...automation is tricky at best.  I actually had better luck setting up WinRM and issuing commands over that.

  • Richard Mueller edited Revision 3. Comment: Modified title and tags

  • Naomi  N edited Revision 4. Comment: Minor edit

  • Richard Mueller edited Revision 6. Comment: Changed tag "Server Core for Windows Server 2008" to "Server Core". We already have tag "Windows Server 2008". Also removed tag "WS08"

Page 1 of 1 (8 items)