I have helped a lot of Sauce Labs users, and one of the common challenges is setting up a Sauce Connect tunnel in order to test against your internal environment.
The first thing you need to do is download and install the tunnel. It is a standalone command line executable available for Windows, Mac, and Linux. I recommend using Linux.
You can download Sauce Connect at:
Once downloaded, you need to extract the package to get the ‘sc’ binary from the /bin directory.
tar -xvzf sc-4.5.4-linux.tar.gz
To start the tunnel, simply pass your Sauce Labs username and access key from the command line or set the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables:
sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -i $TUNNEL_IDENTIFIER
There are quite a few other options that can be passed, and I won’t talk about them here, but you can see them by typing
sc --help at the command line or by reading the documentation here:
In order to start a tunnel for the Sauce Labs mobile real device cloud, you need to pass 1 additional parameter to point the the mobile datacenter. You also need to specify a different API KEY (see screenshot below).
So your command should look something like this:
sc -x https://us1.api.testobject.com/sc/rest/v1 -u $SAUCELABS_USERNAME -k $SAUCECONNECT_API_KEY -i $TUNNEL_IDENTIFIER
See also the sample script sauce-connect.sh that includes additional parameters for setting different port number, log file, etc. (which will conflict if you run on the same host as another tunnel.
Here is the full documentation for real device tunnels: