跳转至内容
  • 最近帖子
  • 0 未读帖子 0
  • 板块分类
  • 开发计划
  • 服务状态
  • 跳转官网
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(不使用皮肤)
  • 不使用皮肤
折叠

OhMySSH

O 7
G

gorocx

@gorocx
关于
帖子
1
主题
1
群组
0
粉丝
0
关注
0

帖子

最新 最佳 有争议的

  • 写了个脚本,转换~/.ssh/config配置成xterminal格式的json
    G gorocx

    有需要的自取

    import random
    from sshconf import read_ssh_config
    from os.path import expanduser
    import json
    from datetime import datetime
    
    c = read_ssh_config(expanduser("~/.ssh/config"))
    
    
    def load_private_key(key_path):
        with open(expanduser(key_path), "r") as key_file:
            key = key_file.read()
        return key
    
    
    def rand_id(length=24, chars="abcdefghijklmnopqrstuvwxyz0123456789"):
        return "".join(random.choice(chars) for i in range(length))
    
    
    def utc_datetime_str():
        return datetime.now().strftime("%Y-%m-%dT%H:%M:%S+08:00")
    
    
    jump_hosts = {}
    hosts = c.hosts()
    for host in hosts:
        host_config = c.host(host)
        if "proxyjump" in host_config:
            jump_host = host_config["proxyjump"]
            jump_hosts[host] = jump_host
    
    config = {"groups": [], "servers": []}
    
    for host in hosts:
        host_config = c.host(host)
        server = {
            "title": host,
            "host": host_config["hostname"],
            "port": host_config["port"],
            "authType": "privateKey",
            "connectionConfig": {"connectOptions": {"algorithms": {}}, "init": {}},
            "username": host_config["user"],
            "privateKey": load_private_key(host_config["identityfile"]),
            "_id": rand_id(),
            "createdAt": utc_datetime_str(),
            "updatedAt": utc_datetime_str(),
            # 自己实现sshProxy逻辑
        }
        config["servers"].append(server)
    
    
    with open("config.json", "w") as f:
        json.dump(config, f, indent=4)
    
    
  • 登录

  • 没有帐号? 注册

  • 登录或注册以进行搜索。

16

在线

3.8k

用户

1.8k

主题

6.1k

帖子
雨云500M带宽服务器推荐🔥
  • 第一个帖子
    最后一个帖子
0
  • 最近帖子
  • 未读帖子 0
  • 板块分类
  • 开发计划
  • 服务状态
  • 跳转官网