https://github.com/jeremyskinner/ssh-config-parser
C#/.NET parser for OpenSSH config files
https://github.com/jeremyskinner/ssh-config-parser
csharp netstandard openssh openssh-config ssh ssh-config
Last synced: 11 months ago
JSON representation
C#/.NET parser for OpenSSH config files
- Host: GitHub
- URL: https://github.com/jeremyskinner/ssh-config-parser
- Owner: JeremySkinner
- License: mit
- Created: 2018-06-16T22:14:46.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-18T16:51:28.000Z (about 8 years ago)
- Last Synced: 2025-04-21T09:52:59.739Z (about 1 year ago)
- Topics: csharp, netstandard, openssh, openssh-config, ssh, ssh-config
- Language: C#
- Size: 33.2 KB
- Stars: 10
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SSH Config File Parser for .NET
This is a parser for the OpenSSH config file format written in .NET. It is a port of https://github.com/dotnil/ssh-config.
# Usage
```
# Assuming the following config file
Host server1
HostName server1.jeremyskinner.co.uk
IdentityFile ~/.ssh/id_rsa
```
```csharp
var config = SshConfig.ParseConfig("path/to/ssh/config");
// Find a host
var host = config.Find("server1");
Console.WriteLine(host.Host); // server1
Console.WriteLine(host.HostName); // server1.jeremyskinner.co.uk
Console.WriteLine(host.IdentityFile); // ~/.ssh/id_rsa
// Also accessible via indexer along with any other properties
Console.WriteLine(host["Host"]);
Console.WriteLine(host["HostName"]);
// Add a new host
config.Add(new SshHost
{
Host = "server2.jeremyskinner.co.uk",
IdentityFile = "~/.ssh/id_rsa"
});
// Convert the config back to a string which can be written to the .ssh/config file
string rawOutput = config.ToString();
```