Basilic

Q: add preferred wireless network

I want to setup preferred wireless networks on a pool of 25 computers in one go while no console/GUI/admin users are logged in, ie computers are started up waiting on the logging screen. All computers are correctly configured for "remote management" access.

 

I am looking for a trick in Apple Remote Desktop to add some preferred wireless networks with the terminal command "networksetup" to these remote computers

 

I have the terminal command right:

sudo networksetup -addpreferredwirelessnetworkatindex en0 ssid 0 wpa2 password

 

Any help?

MacBook Pro with Retina display, OS X El Capitan (10.11.6)

Posted on Sep 27, 2016 8:14 AM

Close

Q: add preferred wireless network

  • All replies
  • Helpful answers

  • by dwbrecovery,Helpful

    dwbrecovery dwbrecovery Oct 3, 2016 9:17 AM in response to Basilic
    Level 3 (596 points)
    Servers Enterprise
    Oct 3, 2016 9:17 AM in response to Basilic

    Hi Basilic,

     

    - A trick that should work can use the ARD Agent from the Admin Mac, to run ssh sessions through the ARD Agents on the clients, which then run the terminal command.

    - I used a script like this previously to restart locked up ARD Agents on clients via ssh.  No GUI sesssions were running on the clients.

     

    The Unix script in ARD would be similar to:

     

    for N in "client1.local" "client2.local" "clientn.local"

      do

    {

       ssh "$N" "sudo networksetup -addpreferredwirelessnetworkatindex en0 ssid 0 wpa2 password"

    }

      done

     

    - The script is run using an adminuser which is available on each client with ssh keys setup ( no password prompts ) and an entry in /etc/sudoers so the sudo command does not prompt for a password either.

    - The adminuser can be enabled for this task in a seperate scripts:

     

    Disable: chsh -s /usr/bin/false adminuser   

    Enable:  chsh -s /bin/bash administer     

     

    hope this helps, dwbrecovery

  • by Basilic,

    Basilic Basilic Oct 3, 2016 9:16 AM in response to dwbrecovery
    Level 1 (4 points)
    Servers Enterprise
    Oct 3, 2016 9:16 AM in response to dwbrecovery

    Hi dwbrecovery

    Thanks for your help! However would you please give me more details on how to do that

    - using an adminuser which is available on each client with ssh keys setup ( no password prompts )

    - an entry in /etc/sudoers

     

    I think your trick may help me modify preference files like /library/preferences/com.apple.loginwindow.plist which tends to be reluctant to be altered from ARD

  • by dwbrecovery,

    dwbrecovery dwbrecovery Oct 4, 2016 8:01 AM in response to Basilic
    Level 3 (596 points)
    Servers Enterprise
    Oct 4, 2016 8:01 AM in response to Basilic

    Hi again,

    Agree, appears that networksetup can only run in a terminal environment.

    The links below should give a guide.

    - an entry in /etc/sudoers;  usage-in-sudo-passwd-nopasswd

    - using an adminuser which is available on each client;   make-passwordless-ssh-connection-osx   


    cheers, dwbrecovery