1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
|
NAME
Shelldap - A program for interacting with an LDAP server via a
shell-like interface
DESCRIPTION
Shelldap /LDAP::Shell is a program for interacting with an LDAP server
via a shell-like interface.
This is not meant to be an exhaustive LDAP editing and browsing
interface, but rather an intuitive shell for performing basic LDAP tasks
quickly and with minimal effort.
SYNPOSIS
shelldap --server example.net [--help]
FEATURES
- Upon successful authenticated binding, credential information is
auto-cached to ~/.shelldap.rc -- future loads require no command line
flags.
- Custom 'description maps' for entry listings. (See the 'list' command.)
- History and autocomplete via readline, if installed.
- Automatic reconnection attempts if the connection is lost with the
LDAP server.
- Basic schema introspection for quick reference.
- It feels like a semi-crippled shell, making LDAP browsing and editing
at least halfway pleasurable.
OPTIONS
All command line options follow getopts long conventions.
shelldap --server example.net --basedn dc=your,o=company
You may also optionally create a ~/.shelldap.rc file with command line
defaults. This file should be valid YAML. (This file is generated
automatically on a successful bind auth.)
Example:
server: ldap.example.net
binddn: cn=Manager,dc=your,o=company
bindpass: xxxxxxxxx
basedn: dc=your,o=company
tls: yes
tls_cacert: /etc/ssl/certs/cacert.pem
tls_cert: ~/.ssl/client.cert.pem
tls_key: ~/.ssl/private/client.key.pem
configfile
Optional. Use an alternate configuration file, instead of the
default ~/.shelldap.rc.
--configfile /tmp/alternate-config.yml
-f /tmp/alternate-config.yml
This config file overrides values found in the default config, so
you can easily have separate config files for connecting to your
cn=monitor or cn=log overlays (for example.)
server
Required. The LDAP server to connect to. This can be a hostname, IP
address, or a URI.
--server ldaps://ldap.example.net
-H ldaps://ldap.example.net
binddn
The full dn of a user to authenticate as. If not specified, defaults
to an anonymous bind. You will be prompted for a password.
--binddn cn=Manager,dc=your,o=company
-D cn=Manager,dc=your,o=company
basedn
The directory 'root' of your LDAP server. If omitted, shelldap will
try and ask the server for a sane default.
--basedn dc=your,o=company
-b dc=your,o=company
paginate
Integer. If enabled, shelldap will attempt to use server side
pagination to build listings. Note: if you're using this to avoid
sizelimit errors, you'll likely need server configuration to raise
the limits for paginated results.
--paginate 100
promptpass
Force password prompting. Useful to temporarily override cached
credentials.
sasl
A space separated list of SASL mechanisms. Requires the Authen::SASL
module.
--sasl "PLAIN CRAM-MD5 GSSAPI"
tls Enables TLS over what would normally be an insecure connection.
Requires server side support.
tls_cacert
Specify CA Certificate to trust.
--tls_cacert /etc/ssl/certs/cacert.pem
tls_cert
The TLS client certificate.
--tls_cert ~/.ssl/client.cert.pem
tls_key
The TLS client key. Not specifying a key will connect via TLS
without key verification.
--tls_key ~/.ssl/private/client.key.pem
cacheage
Set the time to cache directory lookups in seconds.
By default, directory lookups are cached for 300 seconds, to speed
autocomplete up when changing between different basedns.
Modifications to the directory automatically reset the cache.
Directory listings are not cached. (This is just used for
autocomplete.) Set it to 0 to disable caching completely.
timeout
Set the maximum time an LDAP operation can take before it is
cancelled.
debug
Print extra operational info out, and backtrace on fatal error.
version
Display the version number.
SHELL COMMANDS
cat
Display an LDIF dump of an entry. Globbing is supported. Specify
either the full dn, or an rdn. For most commands, rdns are local to
the current search base. ('cwd', as translated to shell speak.) You
may additionally add a list of attributes to display. Use '+' for
server side attributes.
cat uid=mahlon
cat ou=*
cat uid=mahlon,ou=People,dc=example,o=company
cat uid=mahlon + userPassword
less
Like cat, but uses the configured pager to display output.
cd
Change directory. Translated to LDAP, this changes the current
basedn. All commands after a 'cd' operate within the new basedn.
cd change to 'home' basedn
cd ~ change to the binddn, or basedn if anonymously bound
cd - change to previous node
cd ou=People change to explicit path below current node
cd .. change to parent node
cd ../../ou=Groups change to node ou=Groups, which is a sibling
to the current node's grandparent
Since LDAP doesn't actually limit what can be a container object,
you can actually cd into any entry. Many commands then work on '.',
meaning "wherever I currently am."
cd uid=mahlon
cat .
clear
Clear the screen.
copy
Copy an entry to a different dn path. All copies are relative to the
current basedn, unless a full dn is specified. All attributes are
copied, then an LDAP moddn() is performed.
copy uid=mahlon uid=bob
copy uid=mahlon ou=Others,dc=example,o=company
copy uid=mahlon,ou=People,dc=example,o=company uid=mahlon,ou=Others,dc=example,o=company
aliased to: cp
create
Create an entry from scratch. Arguments are space separated
objectClass names. Possible objectClasses are derived automatically
from the server, and will tab-complete.
After the classes are specified, an editor will launch. Required
attributes are listed first, then optional attributes. Optionals are
commented out. After the editor exits, the resulting LDIF is
validated and added to the LDAP directory.
create top person organizationalPerson inetOrgPerson posixAccount
aliased to: touch
delete
Remove an entry from the directory. Globbing is supported. All
deletes are sanity-prompted. The -v flag prints the entries out for
review before delete.
delete uid=mahlon
delete uid=ma*
rm -v uid=mahlon,ou=People,dc=example,o=company l=office
aliased to: rm
edit
Edit an entry in an external editor. After the editor exits, the
resulting LDIF is sanity checked, and changes are written to the
LDAP directory.
edit uid=mahlon
aliased to: vi
env
Show values for various runtime variables.
grep
Search for arbitrary LDAP filters, and return matching dn results.
The search string must be a valid LDAP filter.
grep uid=mahlon
grep uid=mahlon ou=People
grep -r (&(uid=mahlon)(objectClass=*))
aliased to: search
inspect
View schema information about a given entry, or a list of arbitrary
objectClasses, along with the most common flags for the objectClass
attributes.
inspect uid=mahlon
inspect posixAccount organizationalUnit
inspect _schema
The output is a list of found objectClasses, their schema hierarchy
(up to 'top'), whether or not they are a structural class, and then
a merged list of all valid attributes for the given objectClasses.
Attributes are marked as either required or optional, and whether
they allow multiple values or not.
If you ask for the special "_schema" object, the raw server schema
is dumped to screen.
list
List entries for the current basedn. Globbing is supported.
aliased to: ls
ls -l
ls -lR uid=mahlon
list uid=m*
In 'long' mode, descriptions are listed as well, if they exist.
There are some default 'long listing' mappings for common
objectClass types. You can additionally specify your own mappings in
your .shelldap.rc, like so:
...
descmaps:
objectClass: attributename
posixAccount: gecos
posixGroup: gidNumber
ipHost: ipHostNumber
mkdir
Creates a new 'organizationalUnit' entry.
mkdir containername
mkdir ou=whatever
move
Move an entry to a different dn path. Usage is identical to copy.
aliased to: mv
passwd
If supported server side, change the password for a specified entry.
The entry must have a 'userPassword' attribute.
passwd uid=mahlon
pwd
Print the 'working directory' - aka, the current ldap basedn.
setenv
Modify various runtime variables normally set from the command line.
setenv debug 1
export debug=1
whoami
Show current auth credentials. Unless you specified a binddn, this
will just show an anonymous bind.
aliased to: id
TODO
Referral support. Currently, if you try to write to a replicant slave,
you'll just get a referral. It would be nice if shelldap automatically
tried to follow it.
For now, it only makes sense to connect to a master if you plan on doing
any writes.
BUGS / LIMITATIONS
There is no support for editing binary data. If you need to edit base64
stuff, just feed it to the regular ldapmodify/ldapadd/etc tools.
AUTHOR
Mahlon E. Smith <mahlon@martini.nu>
|