|
NAMEssh_file - Default callback module for the client's and server's database operations in the ssh applicationDESCRIPTIONThis module is the default callback handler for the client's and the server's user and host "database" operations. All data, for instance key pairs, are stored in files in the normal file system. This page documents the files, where they are stored and configuration options for this callback module.The intention is to be compatible with the OpenSSH storage in files. Therefore it mimics directories and filenames of OpenSSH. Ssh_file implements the ssh_server_key_api and the ssh_client_key_api. This enables the user to make an own interface using for example a database handler. Such another callback module could be used by setting the option key_cb when starting a client or a server (with for example ssh:connect, ssh:daemon of ssh:shell ). Note:
The functions are Callbacks for the SSH app. They are not intended to be
called from the user's code!
FILES, DIRECTORIES AND WHO USES THEMDaemonsDaemons uses all files stored in the SYSDIR directory.Optionaly, in case of publickey authorization, one or more of the remote user's public keys in the USERDIR directory are used. See the files USERDIR/authorized_keys and USERDIR/authorized_keys2. ClientsClients uses all files stored in the USERDIR directory.Directory contents
The key files could be generated with OpenSSH's ssh-keygen command. At least one host key must be defined. The default value of SYSDIR is /etc/ssh. For security reasons, this directory is normally accessible only to the root user. To change the SYSDIR, see the system_dir option.
It is composed of lines as for OpenSSH: (options)? keytype base64-encoded-key comment where options :: option(,option)* option :: % All options are skipped keytype :: 'ssh-dsa' | 'ssh-rsa' | 'ssh-ecdsa-nistp256' | 'ssh-ecdsa-nistp384' | 'ssh-ecdsa-nistp521' | 'ssh-ed25519' | 'ssh-ed448' base64-encoded-key :: % The user's public key comment :: % Comments are skipped
It is composed of lines as for OpenSSH: (option)? pattern(,pattern)* keytype key (comment)? where option :: '@revoked' pattern :: host | '[' host ']:' port host :: ip-address | hostname | '*' port :: portnumber | '*' keytype :: 'ssh-dsa' | 'ssh-rsa' | 'ssh-ecdsa-nistp256' | 'ssh-ecdsa-nistp384' | 'ssh-ecdsa-nistp521' | 'ssh-ed25519' | 'ssh-ed448' key :: % encoded key from eg ssh_host_*.pub
The key files could be generated with OpenSSH's ssh-keygen command. The default value of USERDIR is /home/LOCALUSER/.ssh. To change the USERDIR, see the user_dir option DATA TYPESOptions for the default ssh_file callback moduleuser_dir_common_option() = {user_dir, string()} Sets the user directory. user_dir_fun_common_option() = {user_dir_fun, user2dir()} user2dir() = fun((RemoteUserName :: string()) -> UserDir :: string()) Sets the user directory dynamically by evaluating the user2dir function. system_dir_daemon_option() = {system_dir, string()} Sets the system directory. pubkey_passphrase_client_options() = {dsa_pass_phrase, string()} | {rsa_pass_phrase, string()} | {ecdsa_pass_phrase, string()} If the user's DSA, RSA or ECDSA key is protected by a passphrase, it can be supplied with thoose options. Note that EdDSA passhrases (Curves 25519 and 448) are not implemented. optimize_key_lookup() = {optimize, time | space} Make the handling of large files fast by setting time, but this will use more memory. The space variant shrinks the memory requirements, but with a higher time consumption. To set it, set the option {key_cb, {ssh_file, [{optimize,TimeOrSpace}]} in the call of "ssh:connect/3, ssh:daemon/2 or similar function call that initiates an ssh connection. EXPORTShost_key(Algorithm, Options) -> Result Types: Algorithm = ssh:pubkey_alg()
Result = {ok, public_key:private_key()} | {error, term()} Options = ssh_server_key_api:daemon_key_cb_options(none()) Types and description See the api description in ssh_server_key_api, Module:host_key/2. Options
Files
is_auth_key(Key, User, Options) -> boolean() Types: Key = public_key:public_key()
User = string() Options = ssh_server_key_api:daemon_key_cb_options(optimize_key_lookup()) Types and description See the api description in ssh_server_key_api: Module:is_auth_key/3. Options
Files
This functions discards all options in the begining of the lines of thoose files when reading them. add_host_key(Host, Port, Key, Options) -> Result Types: Host =
inet:ip_address() |
inet:hostname() |
[inet:ip_address() | inet:hostname()]
Port = inet:port_number() Key = public_key:public_key() Options = ssh_client_key_api:client_key_cb_options(none()) Result = ok | {error, term()} Types and description See the api description in ssh_client_key_api, Module:add_host_key/4. Note that the alternative, the old Module:add_host_key/3 is no longer supported by ssh_file. Option
File
is_host_key(Key, Host, Port, Algorithm, Options) -> Result Types: Key = public_key:public_key()
Host = inet:ip_address() | inet:hostname() | [inet:ip_address() | inet:hostname()] Port = inet:port_number() Algorithm = ssh:pubkey_alg() Options = ssh_client_key_api:client_key_cb_options(optimize_key_lookup()) Result = boolean() | {error, term()} Types and description See the api description in ssh_client_key_api, Module:is_host_key/5. Note that the alternative, the old Module:is_host_key/4 is no longer supported by ssh_file. Option
File
user_key(Algorithm, Options) -> Result Types: Algorithm = ssh:pubkey_alg()
Result = {ok, public_key:private_key()} | {error, string()} Options = ssh_client_key_api:client_key_cb_options(none()) Types and description See the api description in ssh_client_key_api, Module:user_key/2. Options
Note that EdDSA passhrases (Curves 25519 and 448) are not implemented. Files
decode(SshBin, ssh2_pubkey) -> Key
Types: SshBin = binary()
ResultRfc4716 = [{Key, [{headers,Hdrs}]}] | Error ResultOpenSsh = [{Key, [{comment,string()}]}] | Error Key = public_key:public_key() Hdrs = [{Tag::string(), Value::string()}] Error = {error,term()} Decodes an SSH file-binary. If Type is public_key the binary can be either an RFC4716 public key or an OpenSSH public key. Note:
The following key types have been renamed from the deprecated
public_key:ssh_decode/2:
encode(Key, ssh2_pubkey) -> Result
Types: Key = public_key:public_key()
Result = binary() | Error KeyAttrsRfc4716 = [{Key, [{headers,Hdrs}]}] | Error KeyAttrsOpenSsh = [{Key, [{comment,string()}]}] | Error Hdrs = [{Tag::string(), Value::string()}] Error = {error,term()} Encodes a list of SSH file entries (public keys and attributes) to a binary. Note:
The following key types have been renamed from the deprecated
public_key:ssh_encode/2:
Visit the GSP FreeBSD Man Page Interface. |