|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Ssh
|
|
Packit Service |
a2ae7a |
Parses ssh client configuration
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Author: Jiri Suchomel <jsuchome@suse.cz>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Reference
|
|
Packit Service |
a2ae7a |
ssh_config man page
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: License
|
|
Packit Service |
a2ae7a |
This file is licensed under the GPL.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Lens Usage
|
|
Packit Service |
a2ae7a |
Sample usage of this lens in augtool
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(start code)
|
|
Packit Service |
a2ae7a |
augtool> set /files/etc/ssh/ssh_config/Host example.com
|
|
Packit Service |
a2ae7a |
augtool> set /files/etc/ssh/ssh_config/Host[.='example.com']/RemoteForward/machine1:1234 machine2:5678
|
|
Packit Service |
a2ae7a |
augtool> set /files/etc/ssh/ssh_config/Host[.='example.com']/Ciphers/1 aes128-ctr
|
|
Packit Service |
a2ae7a |
augtool> set /files/etc/ssh/ssh_config/Host[.='example.com']/Ciphers/2 aes192-ctr
|
|
Packit Service |
a2ae7a |
(end code)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
module Ssh =
|
|
Packit Service |
a2ae7a |
autoload xfm
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: USEFUL PRIMITIVES
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let eol = Util.doseol
|
|
Packit Service |
a2ae7a |
let spc = Util.del_ws_spc
|
|
Packit Service |
a2ae7a |
let spc_eq = del /[ \t]+|[ \t]*=[ \t]*/ " "
|
|
Packit Service |
a2ae7a |
let comment = Util.comment
|
|
Packit Service |
a2ae7a |
let empty = Util.empty
|
|
Packit Service |
a2ae7a |
let comma = Util.del_str ","
|
|
Packit Service |
a2ae7a |
let indent = Util.indent
|
|
Packit Service |
a2ae7a |
let value_to_eol = store Rx.space_in
|
|
Packit Service |
a2ae7a |
let value_to_spc = store /[^ \t\r\n=][^ \t\r\n]*/
|
|
Packit Service |
a2ae7a |
let value_to_comma = store /[^, \t\r\n=][^, \t\r\n]*/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: ENTRIES
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let array_entry (k:regexp) =
|
|
Packit Service |
a2ae7a |
[ indent . key k . counter "array_entry"
|
|
Packit Service |
a2ae7a |
. [ spc . seq "array_entry" . value_to_spc]* . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let commas_entry (k:regexp) =
|
|
Packit Service |
a2ae7a |
let value = [ seq "commas_entry" . value_to_comma]
|
|
Packit Service |
a2ae7a |
in [ indent . key k . counter "commas_entry" . spc_eq .
|
|
Packit Service |
a2ae7a |
Build.opt_list value comma . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let spaces_entry (k:regexp) =
|
|
Packit Service |
a2ae7a |
let value = [ seq "spaces_entry" . value_to_spc ]
|
|
Packit Service |
a2ae7a |
in [ indent . key k . counter "spaces_entry" . spc_eq .
|
|
Packit Service |
a2ae7a |
Build.opt_list value spc . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let fw_entry (k:regexp) = [ indent . key k . spc_eq .
|
|
Packit Service |
a2ae7a |
[ key /[^ \t\r\n\/=][^ \t\r\n\/]*/ . spc . value_to_eol . eol ]]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let send_env = array_entry /SendEnv/i
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let proxy_command = [ indent . key /ProxyCommand/i . spc . value_to_eol . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let remote_fw = fw_entry /RemoteForward/i
|
|
Packit Service |
a2ae7a |
let local_fw = fw_entry /LocalForward/i
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let ciphers = commas_entry /Ciphers/i
|
|
Packit Service |
a2ae7a |
let macs = commas_entry /MACs/i
|
|
Packit Service |
a2ae7a |
let algorithms = commas_entry /(HostKey|Kex)Algorithms/i
|
|
Packit Service |
a2ae7a |
let pubkey_accepted_key_types = commas_entry /PubkeyAcceptedKeyTypes/i
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let global_knownhosts_file = spaces_entry /GlobalKnownHostsFile/i
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let rekey_limit = [ indent . key /RekeyLimit/i . spc_eq .
|
|
Packit Service |
a2ae7a |
[ label "amount" . value_to_spc ] .
|
|
Packit Service |
a2ae7a |
[ spc . label "duration" . value_to_spc ]? . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let special_entry = send_env
|
|
Packit Service |
a2ae7a |
| proxy_command
|
|
Packit Service |
a2ae7a |
| remote_fw
|
|
Packit Service |
a2ae7a |
| local_fw
|
|
Packit Service |
a2ae7a |
| macs
|
|
Packit Service |
a2ae7a |
| ciphers
|
|
Packit Service |
a2ae7a |
| algorithms
|
|
Packit Service |
a2ae7a |
| pubkey_accepted_key_types
|
|
Packit Service |
a2ae7a |
| global_knownhosts_file
|
|
Packit Service |
a2ae7a |
| rekey_limit
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let key_re = /[A-Za-z0-9]+/
|
|
Packit Service |
a2ae7a |
- /SendEnv|Host|ProxyCommand|RemoteForward|LocalForward|MACs|Ciphers|(HostKey|Kex)Algorithms|PubkeyAcceptedKeyTypes|GlobalKnownHostsFile|RekeyLimit/i
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let other_entry = [ indent . key key_re
|
|
Packit Service |
a2ae7a |
. spc_eq . value_to_spc . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let entry = comment | empty
|
|
Packit Service |
a2ae7a |
| special_entry
|
|
Packit Service |
a2ae7a |
| other_entry
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let host = [ key /Host/i . spc . value_to_eol . eol . entry* ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: LENS
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let lns = entry* . host*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let xfm = transform lns (incl "/etc/ssh/ssh_config" .
|
|
Packit Service |
a2ae7a |
incl (Sys.getenv("HOME") . "/.ssh/config") .
|
|
Packit Service |
a2ae7a |
incl "/etc/ssh/ssh_config.d/*.conf")
|