How to use the ssh-config.stringify function in ssh-config

To help you get started, we’ve selected a few ssh-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sebas5384 / hades / app / lib / ConfigFile.js View on Github external
const update = (items) => {

    const newConfig = sshConfig.parse('')
    // Convert items to the config format and append to the new config.
    items.forEach((item) => {
      const convertedItem = convertToConfigFormat(item)
      newConfig.append(convertedItem)
    })

    const newConfigString = sshConfig.stringify(newConfig);

    const unmanagedConfig = readUnmanagedLocalConfig()

    return unmanagedConfig
      .trim()
      .concat("\n", settings.startTag)
      .concat("\n", newConfigString)
      .concat("\n", settings.endTag)
  }
github ionic-team / ionic-cli / packages / ionic / src / lib / __tests__ / ssh-config.ts View on Github external
it('should stringify with config3 file', async () => {
        const config3 = await readFile(path.resolve(__dirname, 'fixtures/ssh-config/config3'), { encoding: 'utf8' });
        const conf = SSHConfig.parse(config3);
        ensureHostAndKeyPath(conf, { host: 'bar' }, '/id_rsa');
        expect(SSHConfig.stringify(conf)).toEqual(config3);
      });
github ionic-team / ionic-cli / packages / cli-plugin-cloud / src / commands / ssh / use.ts View on Github external
async applyConfig(text: string, keyPath: string): Promise {
    const c = await this.config.load();
    const conf = SSHConfig.parse(text);
    const host = c.git.host;
    const section = this.ensureSection(conf, host, Boolean(text));

    this.ensureSectionLine(section, 'IdentityFile', keyPath);

    if (typeof c.git.port === 'number') {
      this.ensureSectionLine(section, 'Port', String(c.git.port));
    }

    return SSHConfig.stringify(conf);
  }

ssh-config

SSH config parser and stringifier

MIT
Latest version published 1 month ago

Package Health Score

75 / 100
Full package analysis