how to programmatically enable remote management under sharing in Mac OS X 10.8 - objective-c

I am working on a project which requires VNC Server to be run on my system (Mac OS X v10.8).
VNS server is installed in my Mac system, now I need to run VNC server, but for running the server sufficient privileges needs to be provided programmatically or using Apple Script(System Preference -> Sharing -> Remote Management -> Enable the check box).
How could I enable remote management through objective c program or apple script ?
or is there any API provided by Apple to manage sharing options?

You can enable and configure the remote management service with the kickstart command. It's not in the usual PATH, so you need to specify its full path:
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart
Its option format is a little cryptic, but with some experimentation you should be able to get the effect you want (see Apple's KB #HT2370 and SS64.com's "man page").
Also, it must run as root, so from AppleScript, use do shell script with administrator privileges. I think you'll need something close to this:
do shell script "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -restart -agent -privs -all" with administrator privileges

Related

Can we use BLPAPI remotely?

The SDKs at https://www.bloomberg.com/professional/support/api-library/ allow you to connect to localhost 8194 to fetch data. Please correct if any of the following is incorrect:
The use of the SDK requires the installation of a Terminal software on the PC where the program using the SDK is being run.
The Terminal software creates an endpoint listening on port 8194 through which the data can be fetched.
Question:
Is it possible for another computer in the local network to run the SDK and connect to the computer that hosts the Terminal service?
Does the Terminal service license support such use wherein the data leaves the PC and gets pulled to a different PC?
Regards
No, it is not technically possible to connect to another PC which is running the Terminal and even if you can get around this it is not allowed by the license. Data downloaded on a PC running the Terminal must stay on that PC.
Bloomberg offers 2 solutions which don't require the Terminal to run and do require authentication: Server API (SAPI) and B-PIPE. To clarify, because you're describing having to run the Terminal on the PC you're necessarily talking about Desktop API.

Using saltstack ssh

Is there a difference between using salt-proxy ssh and directly salt-ssh? I'm interested because according to documentation both aimed to run remote commands without agent installation on the end machine.
You cant simply do salt-ssh on a proxy minion, for which you would have to write your own custom ssh interface to the remote system, because your proxy minion may not support doing salt-ssh.
How to choose between using salt-ssh vs salt-proxy totally depends on the type of a minion system.
As stated in the saltstack documentation - https://docs.saltstack.com/en/latest/topics/ssh/index.html and
https://docs.saltstack.com/en/latest/topics/proxyminion/index.html
For salt-ssh to be used, the remote system must have python installed - one of the criteria. For example, controlling ubuntu from centos.
As stated in the salt-proxy doc,
Proxy minions are a developing Salt feature that enables controlling
devices that, for whatever reason, cannot run a standard salt-minion.
Examples include network gear that has an API but runs a proprietary
OS, devices with limited CPU or memory, or devices that could run a
minion, but for security reasons, will not.

Creating L2TP VPN on Mac OS X Programatically

I am trying to make application which can be use to connect to VPN using L2TP Protocol for Mac OSX Application using Objective C.
I search a lot regarding this but couldn't find any proper example or tutorial.
I Found halo/macosvpn for mac os vpn connection but it is command line tool i would like to make it in my application.
For E.g If i pass Server id, Shared Secret Key, username, password then my mac should be automatically connect to that VPN Server.
Any help will be appreciated...
No, you need use SCNetwork and Helper Tool (to get root access) With this link you will be able to create L2TP Protocol and connect with it.
This works even on the latest version MacOS 11 "Big Sure"
The helper tool is needed to get root access so you can make changes to the system keychain. You will put the password and shared secret there, because the configuration will not be able to perceive them from other places. Having created a vpn configuration with the help of SCNetwork, the mac will not be able to automatically connect.
To connect to the created profile, you need to programmatically execute the terminal command
networksetup -connectpppoeservice "name VPN profile"

System restart to windows using objective-c

If a users wants to reboot to windows from OS X, he/she either needs to:
a) Reboot holding down the ALT key and select windows
b) Go to System
settings -> Startup disk -> Select windows -> Reboot
(Given that the user has a bootcamp partition and windows installed).
Since I now and then play some games, and prefer doing that directly in Windows and not using e.g. VMWare Fusion. I would like to develop a smarter and easier way of rebooting. I know how to reboot a machine using Objective-c, but how can I choose the boot partition and reboot to it? Basically how the system restart function works in the system settings (choose partition and reboot).
I don't know if there is a programmatic interface, but you can set the startup disk with the bless command, see "man bless".

Get remote cmd from linux termnal

I need to run some scripts in a windows remote machine from a terminal linux, I've tried using telnet however in the windows machine it's unable and there isn't installed a ssh server. So I need other way to run the command remotely without a graphical interface.
I have the possibility for run the command from a windows machine, however I need to open a SSH Tunnel to see the remote machine, I've used psexec but it didn't work for me.
Do you have access to install software on the remote server?
Your SSH client will not be able to connect to the remote machine unless that machine is running an SSH server to respond to your client's connection request.
There are a number of possible options for SSH servers to run on Windows.
(Google for ssh server windows)
Because SSH gives an external user some access to/control over your server it is designed to be a secure tool. I would therefore recommend using an SSH server which is still actively maintained, and keep it up to date. Servers which are old and no longer supported are are likely to contain known security issues which may never be addressed, thereby leaving your server vulnerable.
There are a number of good free open-source solutions for this, so you shouldn't need to buy anything.
In the past I've worked with Windows machines running Cygwin, with the OpenSSH ssh server installed. Depending how much of the Cygwin system you choose to install, it can make the target Windows host rather like logging into another Linux box in terms of environment.
You can download the installer for Cygwin from http://www.cygwin.com/