def test_token_missing(self): with self.assertRaises(Exception) as e: launch_ssh("") exception = e.exception self.assertEqual( str(exception), "Ngrok AuthToken is missing, copy it from https://dashboard.ngrok.com/auth" )
def test_token_is_wrong(self): with self.assertRaises(Exception) as e: launch_ssh(", ") exception = e.exception self.assertEqual( str(exception), "It looks like something went wrong, please make sure your token is valid" )
def runNGROK(): from colab_ssh import launch_ssh from IPython.display import clear_output launch_ssh(ngrokToken, password) clear_output() print("ssh", username, end='@') os.system("bash -c ' curl -s http://localhost:4040/api/tunnels | python3 -c \"import sys, json; print(json.load(sys.stdin)[\'tunnels\'][0][\'public_url\'][6:].replace(\':\', \' -p \'))\"'")
def runNGROK(): from colab_ssh import launch_ssh from IPython.display import clear_output launch_ssh('1nKzuFd4Oe16GysXPLuMhOragQZ_2HxHA13X5Fd1mqSYF4Avr', 'root') clear_output() print("ssh", username, end='@') os.system('''curl -s http://localhost:4040/api/tunnels | python3 -c \ "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'][6:].replace(':', ' -p '))"''' )
def ssh_to_colab(): password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(20)) #Ask token print("Copy authtoken from https://dashboard.ngrok.com/auth") authtoken = getpass.getpass() #Create tunnel launch_ssh(authtoken, password) #Print root password print("Root password: {}".format(password))
def test_success_with_region(ngorkToken): launch_ssh(ngorkToken, verbose=True, region="eu")
def test_success(ngorkToken): launch_ssh(ngorkToken, verbose=True)
def test_token_missing(): with pytest.raises(Exception) as e: launch_ssh("") exception = e.value assert str(exception) == "Ngrok AuthToken is missing, copy it from https://dashboard.ngrok.com/auth"
def test_token_is_wrong(): with pytest.raises(Exception) as e: launch_ssh(", ") exception = e.value assert str(exception) == "It looks like something went wrong, please make sure your token is valid"
from colab_ssh import launch_ssh import os token = os.environ["NGROK_TOKEN"] ssh_password = os.environ["SSH_PASSWORD"] launch_ssh(ssh_password, token)
def test_success_with_region(self): launch_ssh(NGROK_TOKEN, verbose=True, region="eu")
def test_success(self): launch_ssh(NGROK_TOKEN, verbose=True)
#!/usr/bin/python3.8 import json from colab_ssh import launch_ssh from colab_ssh import get_tunnel_config launch_ssh('1ih6ACosTCp4vtqmz0kMEObj6US_4WKtwytKGHJxCH6DThVfr', '777') f = open("/content/connection/service_server_connection_info", "w") f.write(json.dumps(get_tunnel_config())) f.close()