lib/junos-ez/system/users.rb
## ----------------------------------------------------------------
## load an SSH public key  & return the resulting key object.
## You can provide the publickey either as :publickey or
## contents will be read from :filename
## ----------------------------------------------------------------
load an SSH public key  & return the resulting key object.
You can provide the publickey either as :publickey or
contents will be read from :filename
load an SSH public key & return the resulting key object . You can provide the publickey either as : publickey or contents will be read from : filename
def load_ssh_key!( opts = {} )
    publickey = opts[:publickey] || File.read( opts[:filename] ).strip
    raise ArgumentError, "no public-key specified" unless publickey
    @auth_provd ||= get_userauth_provd    
    raise StandardError, "No Junos::Ez::UserAuths::Provider" unless @auth_provd
    keytype = publickey[0..6]
    keytype = 'ssh-dsa' if keytype == 'ssh-dss'
    raise ArgumentError, "Unknown ssh key-type #{keytype}" unless Junos::Ez::UserAuths::VALID_KEY_TYPES.include? keytype
    key_name = {:user => @name, :keytype => keytype, :publickey => publickey }
    key = @auth_provd[ key_name ]
    key.write!
    key
  end
def load_ssh_key! ( opts = { } ) publickey = opts [ :publickey ] || File . read ( opts [ :filename ] ) . strip raise ArgumentError , "no public-key specified" unless publickey @auth_provd ||= get_userauth_provd raise StandardError , "No Junos::Ez::UserAuths::Provider" unless @auth_provd keytype = publickey [ 0 .. 6 ] keytype = 'ssh-dsa' if keytype == 'ssh-dss' raise ArgumentError , "Unknown ssh key-type #{keytype}" unless Junos :: Ez :: UserAuths :: VALID_KEY_TYPES . include? keytype key_name = { :user => @name , :keytype => keytype , :publickey => publickey } key = @auth_provd [ key_name ] key . write! key end
load an SSH public key  & return the resulting key object.
load an SSH public key & return the resulting key object .
# nab the provider for handling ssh-keys, since we'll use that # for key resource management # extract the key-type from the public key. # ok, we've got everything we need to add the key, so here we go. # return the key in case the caller wants it
opts
<not_specific>