How to programatically create a VPN connection on Mac OS X? - macos

I have a config file that completely describes how to connect to a VPN. I'd like to write a tool (C or Objective-C) to read in the file and then create a new VPN interface on the system.
I'm guessing the answer will have something to do with SCNetworkServiceCreate and/or SCNetworkInterfaceCreateWithInterface. Both of these want to bind to another interface. What stumps me is that, in theory, the VPN connections should ride on top of any IP interface so I'm at a loss what to use for the base interface.
Any help or pointers would be greatly appreciated.

macosvpn is a command line tool written in Objective-C over on GitHub which allows you to "Create Mac OS VPNs programmatically". E.g. to add a L2TP over IPSec VPN service you would do this:
sudo macosvpn create --l2tp Atlantic --endpoint atlantic.example.com --username Alice --password p4ssw0rd --shared-secret s3same
It should be straightforward to read your config file params into the command's flag args.
As of today macosvpn is available via Homebrew: brew install macosvp. Xcode is a build requirement.

Answering this for completeness.
So, the answer is not well documented. However, there is a magical constant interface definition for any protocol that you want to ride on top of the currently connected IPv4 interface, kSCNetworkInterfaceIPv4.
Therefore the code to create a new VPN builds the VPN stack on top of that interface.

Related

SIP 408 Request Timeout for Freeswitch

I am trying to create an account on Zoipher. Saw some articles over here regarding the configuration and setup. I have freeswitch installed on docker. I came across one similar article here where someone else is facing the same problem but that is for Asterisk. Also, they are referring to create a SIP account in sip.conf. However, I couldn't find anything existing inside my freeswitch directory where I can create a SIP account before creating it on Zoipher softphone. Please let me know
The default FreeSWITCH configuration already has users 1000 to 1019, with the password 1234. There's a directory/ folder with a bunch of XML in it.
The best and the quickest way to learn FreeSWITCH is with their book: https://www.packtpub.com/networking-and-servers/freeswitch-12
or through training (I did some training for a small team, can do that again)
You can find SIP users' accounts in the <freeswitch home directory>/conf/directory/default. There are XML files with sip accounts, inside them you can configure UserID and passwords for SIP users.
I wouldn't recommend using Docker for a VoIP server before Docker supports port ranges. You need to configure it to map UDP port ranges for RTP, and with current version of Docker you can only list every port explicitly. In the next release, they promise to support port ranges.

Check on avaiable port using wmi win32 class?

I am using inno setup to make an installation file. It required to pull local ip address (which I able to do by querying Win32_NetworkAdapterConfiguration) and check if a specific port is open for the software to run on (which I am currently looking for an answer).
I realize that WMI Win32 classes contain so many useful information. So I wonder which Win32 class should I use to check on this port given that if it is possible to do that?
Thank you,
AFAIK the only WMI class to check if a given port is open is the NetDiagnostics WMI class and the ConnectToPort method, but this class only is present in Windows XP. So if you want an option which works in another Windows versions you can try to import (or write your own application and invoke from inno) something like the Winsock connect function, like is show on this question How to check if a TCP port is available with Delphi?
Just try to bind a socket to it. If it succeeds, it's available.

controlling a remote machine

I want to develop some kind of automation system i can control some pcs in my network.Features i am looking to develop are as follows:
1)Ability to establish a connection with some remote systems and executing some commands on those
2)Ability to transfer files from main controller pc to those pcs
3)Ability to get status of other pc
I dont want to install some explicit server on each of the client machines , and want to use some in built protocol /services running on windows a my clinets are windows.
The only this available with my controller pc is Administator user name and passwd and clinet machine ips.
IBM TPM uses some port to do such things but am not usre which protocal /service it uses?
I have done a remote software installation using ibm tpm.I dont think it uses telnet or ssh.
Which inbuilt service/protocol i should use? (not telnet or ssh)
I need to design a tool that can install software on remote client machine.
Basically i need Deploy MSI, EXE, BAT etc. on various client machines without user interaction.
There are lots of tool on net that provide these features but i need to develop such type of utility.
Please suggest
you can setup remote desktop on the machines.
For Establishing command : you can setup remote desktop
For transferring files: You can map drives of other machines programmatically using the method WNetAddConnection2().
Its unmanaged code ...
This might help :
http://vbnet.mvps.org/index.html?code/network/wnetaddconnection2.htm
http://www.pinvoke.net/default.aspx/mpr/wnetaddconnection2.html

Issue setting up GIT with SSH on Windows Server 2008

I´m following the steps outlined in Tim Davis´ blog for setting up GIT with copSSH on Windows (http://www.timdavis.com.au/git/setting-up-a-msysgit-server-with-copssh-on-windows/) but I´m having problems. I´ve gotten up to step 15 under the Installing Putty instructions but rather than getting a "Enter Login" message, I´m getting a "Network Error: Unable to connect to server" error.
I know that it could potentially be a myriad of things but I was wondering if by some miracle, someone could give me some ideas of what else I should check?
I´ve doublechecked the following:
IP address is correct
User has been added to copSSH
Key is stored in the specified user folder
Rule has been added to Firewall
(NOTE: We´re using a server on 1and1.com and the firewall rules allow us to specify a local port and a remote port. Have configured to local port 4837 and remote port to Any).
I tried to doublecheck if the SSH service is running but I don´t know what it´s called. I noted down the username and password from the copSSH setup but I haven´t seen anything remotely similar to SSH in the list of services.
Any help would be greatly appreciated!! I´ve never had to do something like this before so I´m a little lost.
Regards,
Kat
Troubleshooting
Are you specifying port 4837 in the Putty window?
I personally suggest using OpenSSH or SmartGit, not Putty... I've seen too many issues with it.
Also, I suspect your firewall configuration needs to be local port=Any and remote port=4837.
The 5 minute shortcut
This installer sets up a windows git server using CopSSH. It configures the firewall, the user accounts, and gives you a GUI for all the SSH and keys stuff. It costs $9, but it saves hours of configuration (it's a 5 minute, 3-step install). It has a self-contained Git install, so no conflicts should happen.
NOTE: I'm the webmaster of windowsgit.com. I got the project started after taking a good look at Davis' tutorial and thinking.... oh, ----! The CopSSH author and I collaborated to make the automate the process and reduce the number of frustration-related keyboard deaths :)

Speeding up ssh in batch files

This is my situation:
I have a linux server/media center with a windows client.
My goal is to remote control rhythmbox amongst other things.
I've done this using plink (windows based cli ssh toy).
The problem is that starting up an ssh session logging in and sending a command is understandably slow as hell. When I had a windows server I used a tool called psexec which was almost instantaneous.
Is there any way to speed this process up? Either somehow sending the commands with the login request which should show some improvement. Or by maintaining a persistent ssh connection which I can use. (plink dcs at the end of the command).
More info: On my windows machine I'm using a bat like:
plink -ssh -l username -pw pass myipaddress "/home/username/bin/skip"
On my linux machine the skip bash file is something like:
//needed to get around a x11 error caused by controlling rhythmbox over sshif its an ssh connection copy the dbusaddressfirhythmbox-client --next //the cli wrapper for rhythmbox
Further Research:
The only way to go seems to keep an ssh connection open/maintained as a service. This seems doable as there is a demand due to setting up ssh tunnels (to bypass firewalls). From there I'd need a way to send the command line commands to this existing connection or reuse that connection.
The other option is of course to NOT use ssh. Hell I already have a connection through samba file shares and there is no lag there. I bet I could put a service linux side that checks for a modified file. Then have an ap client side that modifies said file. Amazingly hacky but so far it seems like the best option. And by best I mean the only one that cuts control lag. There has got to be a better way than this, I can't be the only nerd using linux as a media-center that wants remote controls. This kind of moves the topic from stackoverflow to superuser but that's ok.
You could user an SSL certificate to get rid of the login part. Alternatively, build yourself a small HTTP server which uses an "exotic" port for controlling your media player (amarok, btw, has one build-in)
Switching to something like mpd will bypass the ssh issue, although I give no guarantee that changing tracks will be any faster.
If anyone is curious, I ended up implementing an http based server with php to execute commands server side. And client side I used curl.exe to allow me to have nice click-able buttons without the overhead of a web-browser.
Also nice since it allowed me to implement an in browser UI which is great to use from any machine with internet, ones that don't have ssh installed. And works wonderfully from my phone as a remote control (which I can use from a country away if I so chose...)

Resources