teleport icon indicating copy to clipboard operation
teleport copied to clipboard

linux client?

Open MaymayJay opened this issue 5 years ago • 4 comments
trafficstars

有没有linux客户端?

MaymayJay avatar Feb 21 '20 01:02 MaymayJay

同求~

linuxopsc avatar Feb 26 '20 08:02 linuxopsc

手工实现了下linux ssh,通过py启动一个http服务,然后会输入日志,比如:ssh [email protected] -p 52189 ,复制然后运行就能登陆,密码随便

#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
    ./server.py [<port>]
"""

import logging
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse, quote, unquote
import json


class MyRequest(BaseHTTPRequestHandler):
    def _set_response(self):
        self.send_response(200)
        self.send_header('Content-type', 'application/json')
        self.send_header('Access-Control-Allow-Origin', '*')
        self.end_headers()

    def do_GET(self):
        logging.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers))

        if self.path == "/api/get_version":
            self._set_response()
            self.wfile.write('{"code":0,"version":"3.3.3"}'.encode('utf-8'))

        if '/api/run' in self.path:
            self._set_response()
            tmp = urlparse(self.path)

            req = json.loads(unquote(tmp.path).replace('/api/run/', ''))
            print("ssh {}@{} -p 52189".format(req['session_id'], req['teleport_ip']))
            self.wfile.write('{"code":0}'.encode('utf-8'))


def run(server_class=HTTPServer, handler_class=MyRequest, port=50022, ip='127.0.0.1'):
    logging.basicConfig(level=logging.INFO)
    server_address = (ip, port)
    httpd = server_class(server_address, handler_class)
    logging.info('Starting httpd {}:{} ...\n'.format(server_address[0], server_address[1]))
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()
    logging.info('Stopping httpd...\n')


if __name__ == '__main__':
    run()

ijackwu avatar Mar 28 '20 15:03 ijackwu

+1

zhashuyu avatar Apr 26 '20 01:04 zhashuyu

手工实现了下linux ssh,通过py启动一个http服务,然后会输入日志,比如:ssh [email protected] -p 52189 ,复制然后运行就能登陆,密码随便

#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
    ./server.py [<port>]
"""

import logging
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse, quote, unquote
import json


class MyRequest(BaseHTTPRequestHandler):
    def _set_response(self):
        self.send_response(200)
        self.send_header('Content-type', 'application/json')
        self.send_header('Access-Control-Allow-Origin', '*')
        self.end_headers()

    def do_GET(self):
        logging.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers))

        if self.path == "/api/get_version":
            self._set_response()
            self.wfile.write('{"code":0,"version":"3.3.3"}'.encode('utf-8'))

        if '/api/run' in self.path:
            self._set_response()
            tmp = urlparse(self.path)

            req = json.loads(unquote(tmp.path).replace('/api/run/', ''))
            print("ssh {}@{} -p 52189".format(req['session_id'], req['teleport_ip']))
            self.wfile.write('{"code":0}'.encode('utf-8'))


def run(server_class=HTTPServer, handler_class=MyRequest, port=50022, ip='127.0.0.1'):
    logging.basicConfig(level=logging.INFO)
    server_address = (ip, port)
    httpd = server_class(server_address, handler_class)
    logging.info('Starting httpd {}:{} ...\n'.format(server_address[0], server_address[1]))
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()
    logging.info('Stopping httpd...\n')


if __name__ == '__main__':
    run()

密钥随便吗? 随便填不行啊 ,ssh [email protected] -p 52189 输入后还是要密码的

MinJW avatar Oct 29 '20 03:10 MinJW