When I start an ngrok client with ./ngrok tcp 22 it runs in the foreground and I can see the randoming generated forwarding URL, such as tcp://0.tcp.ngrok.io:
./ngrok tcp 22
tcp://0.tcp.ngrok.io:
In Ruby
require 'httparty' # get ngrok public url begin response = HTTParty.get 'http://localhost:4040/api/tunnels' json = JSON.parse response.body new_sms_url = json['tunnels'].first['public_url'] rescue Errno::ECONNREFUSED print 'no ngrok instance found. shutting down' exit end