Accessing/controlling a Windows PC from your WDTV

From WikiDLXTV
Jump to: navigation, search

A guide on setup and implementation to access and control a Windows based pc from your WDTV via ssh

1. Windows user setup -

  First thing needed is for you to create a user with administrative rights. The breakdown here is for Windows Vista and 7 
  (I'm sure it can be implemented in similar fashion on other versions of windows also). Start by going to the Control panel,
  in the control panel select administrative tools. Once in administrative tools on the left pane select 'Local Users and Groups'. 
  Within there select 'Users', moving now into the center pane, right click and select New User and enter a user name that will
  be used for your WDTV, enter a password also, a password is required to get this to work but will only be entered once to 
  allow the initial connection to be made. Uncheck 'User must change password at next login' and check 'Password never expires'
  then hit create. Once the user name appears in the center pane select it by right clicking and selecting properties. Once in
  properties select the 'Member Of' tab. Click the 'Add' button at the bottom of the window, in the 'Enter the object names to
  select' box enter "Administrators" without the quotes. Click 'Check Names' to verify that "Administrators" is a group within
  your PC and then hit ok. (Note: If Administrators isn't a group in your PC then you need to add it back in. It is a default
  group and should always be present.)

2. Setup ssh on your windows pc -

  Download yourself one of the free ssh servers that are floating around the net;
  Mobassh - http://mobassh.mobatek.net/en/telechargement/93.html "My personal choice ;) but what do I know"
  freeSSHd - http://www.freesshd.com/freeSSHd.exe  
  OpenSSH - http://sourceforge.net/projects/sshwindows/files/OpenSSH%20for%20Windows%20-%20Release/
  WinSSHD - http://www.bitvise.com/download-area 'this one is limited to 30 days unless purchased'
  
  Install one of these servers as a service in windows and add the username that you created in Step 1 if necessary. I'm not 
  going to go into detail on setting up all of these but rest assured they all work. You can test if the services is running
  correctly by logging in with an app like Putty. You can login using
  'localhost' (127.0.0.1). Your next step entails you opening the ssh port of 22 in your firewall. I can't go into specifics on
  that because i don't know what firewall your running, so you'll have to figure it out on your own if the port needs to be
  opened. 

3. Create password-less access to your Windows PC

  You now need to log into your WDTV using the root login. Once you've logged in and have a terminal window you now need
  to establish a password-less connection to your Windows PC. Start by entering this code below

  Code: ssh-copy-id username@<your machines ip>

  When asked for a password enter the password associated with the username you created in Windows.
  The next prompt will be this
  -
  The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established.
  RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
  Are you sure you want to continue connecting (yes/no)?
  Answer "yes" to this question. The following statement will be
  -
  Warning: Permanently added 'xxx.xxx.xxx.xxx' (RSA) to the list of known hosts.
  Now try logging into the machine, with "ssh 'username@<your machines ip>'", and check in:
   .ssh/authorized_keys
  to make sure we haven't added extra keys that you weren't expecting.
  -
  If you've reached this point you have established password-less access to your Windows PC and can now manage it from your 
  WDTV unit via ssh using some simple commands.

One forseeable error:

  You already have an RSA key in the 'known_hosts' file, your output would then be
    
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
  Someone could be eavesdropping on you right now (man-in-the-middle attack)!
  It is also possible that the RSA host key has just been changed.
  The fingerprint for the RSA key sent by the remote host is
  xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
  Please contact your system administrator.
  Add correct host key in /root/.ssh/known_hosts to get rid of this message.
  Offending key in /root/.ssh/known_hosts:1
  RSA host key for 192.168.0.100 has changed and you have requested strict checkin      g.
  Host key verification failed.
   
  A simple fix to this problem is to delete the '/tmp/conf/known_hosts' file and then proceed to step 3.


Implementations:

  ssh username@<your machines ip> c:/windows/system32/shutdown.exe /h  'note the forward slashes vs. the back slashes' (puts 
  the pc into hibernation)
  ssh username@<your machines ip> c:\\windows\\system32\\shutdown.exe /h 'is another alternative to the same end'
  -
  Restarting of an application/service
  ssh username@<your machines ip> "net stop NFSserver"     
  ssh username@<your machines ip> "net start NFSserver"
  or combined:
  ssh username@<your machines ip> cmd /c net stop NFSserver ; net start NFSserver

Props to 'sailort' for leading me in the right direction. Original post http://forum.wdlxtv.com/viewtopic.php?f=43&t=1877