Provides common user ssh client operations and remote filesystem mounting using sshfs.
Add public key
Add a ssh public key to a remote users authorized_keys file.
Generate SSH key pair
Mount using sshfs
Reset ssh key
Reset the remote users authorized_keys file to only hold one pub key.
The pub key uploaded should be the current one being used by you.
SSH into remote machine
- forward
- reverse
- socks
- wrap_reverse
Unmount sshfs mountpoint
Wrap other command in SSH call.
You could have a list of remote hosts
to connect through, a.k.a. jump hosts.
Make sure that OpenSSH is installed.
- 0: dependencies found
- 1: failed to find dependencies
Connect to remote server over SSH.
Optionally use one or more "jump servers"
-
$1: host address, or many space separated addresses if using jump hosts.
-
Last address is the final destination host.
-
$2: Optional matching list of user names.
-
$3: Optional matching list of key files.
-
$4: Optional matching list of ports. e.g. "223 22 222"
-
$5: Optional matching list of flags. e.g. "q q q"
-
$6: Optional shell to use on remote side, leave empty for default
-
login shell. e.g. "sh" or "bash".
-
$7: Optional command to execute on server, leave blank for interactive shell.
-
The parameter lists do not have to be as long as the "hosts" list, if they
-
are not then no or a default value is used.
-
To put an item in the middle of a list as empty use ''.
-
To have a space within a single value, say when using multiple flags,
-
put a semicolon ";" between flags, this semicolon will later be substituted for a space.
-
We can't put a space directly between flags for the same command since it will be split
-
and treated as flags for different commands.
- non-zero on error
Helper macro
-
out_sshcommand
-
SSH/SSH_FS variables
-
Return:
-
non-zero on error
Wrapper over SSH that uses environment
variables instead of positional arguments.
If connecting to multiple hosts the variables must be balanced,
see the SSH function for more information.
- SSHHOST:
- SSHUSER: optional
- SSHKEYFILE: optional
- SSHPORT: optional - defaults to 22.
- SSHFLAGS: optional
- SSHSHELL: optional
- non-zero on error.
Generate a SSH key pair.
- $1: Path of the private key to create. The pub key will have the prefix ".pub".
- $2: file path where to copy the pub key to after generation (optional).
- 0: success
- 1: failure
Setup sshfs onto a remote machine, possibly via jump host(s).
-
$1: remotepath, path on remote server to mount
-
$2: localpath, local path to mount to
-
$3: host address, or many space separated addresses if using jump hosts.
-
Last address is the final destination host.
-
$4: Optional matching list of user names.
-
$5: Optional matching list of key files.
-
$6: Optional matching list of ports. e.g. "223 22 222"
-
$7: Optional matching list of flags. e.g. "q q q"
-
$8: Optional shell to use on remote side, leave empty for default
-
login shell. e.g. "sh" or "bash".
-
$9: Optional command to execute on server, leave blank for interactive shell.
-
The parameter lists do not have to be as long as the "hosts" list, if they
-
are not then no or a default value is used.
-
To put an item in the middle of a list as empty use ''.
- non-zero on error
Umount a sshfs mount point.
- $1: local path
Add a SSH public key to a users authorized_keys file.
- $1: The name of the existing user to add ssh key file for
- $2: Path to the pub key file to upload for the target user
Clear all authorized keys and re-add the current users pub key as the only one.
This is useful to revoke all other admins access to the machine.
- $1: The name if the existing user to add ssh key file for.
- $2: Path to the pub key file to upload for the target user.