cryptsetup-ssh - Linux


Cryptsetup-ssh is a command-line utility that allows you to securely map a remote disk over SSH. It encrypts volumes using a passphrase and opens them automatically when the SSH connection is established.


cryptsetup-ssh [options] <subcommand> [arguments]


  • attach: Attach remote disk.
  • detach: Detach remote disk.
  • switch: Attach/detach on demand.
  • open: Open remote disk manually.
  • close: Close remote disk manually.
  • init: Initialize remote disk.
  • destroy: Destroy remote disk.
  • resize: Resize remote disk.


  • -s, –source: Remote host IP address or hostname.
  • -p, –port: SSH port number. Default: 22.
  • -u, –user: SSH username.
  • -P, –passphrase: Passphrase for encrypted volume (stdin if not specified).
  • -f, –filesystem: Filesystem used in remote disk. Default: ext4.
  • -i, –init: Initialize remote disk with LUKS.
  • -d, –destroy: Destroy remote disk.


Attach Remote Disk with Passphrase:

cryptsetup-ssh attach -s my-disk

Attach with Automatic SSH Key Authentication:

cryptsetup-ssh attach -s my-disk -u user

Initialize Remote Disk with LUKS:

cryptsetup-ssh init -s my-disk

Common Issues

  • Connection Refused: Ensure SSH is running on the remote host and that the SSH key is authorized.
  • Authentication Failed: Verify the SSH user and passphrase.
  • Could Not Open Remote Disk: Check if the SSH connection is stable and the remote disk is not already in use.


Cryptsetup-ssh can be combined with cron jobs or systemd units to automatically attach/detach disks based on scheduled tasks or events.

Related Commands

  • cryptsetup: Control encrypted volumes on local systems.
  • sshfs: Mount remote filesystems over SSH.