The easiest way to make an image:
ssh root@raspberrypi cat /dev/sda >rpi.img
This creates a large raw copy. If you want to compress the file, you should first fill the unused disk space with a compressible pattern. Run this command in any on-disk directory (if you run multiple partitions, do it for it partition):
cat /dev/zero >zero; rm zero
cat rpi.img >/dev/sda after booting from some external media (replace
sda by the right designation for the internal storage).
This is not necessarily the best way to make an image for an identical installation. If you only want to save your settings, you only need to back up a few things:
You can then restore an identical system by doing a minimal installation, restoring the packages (see Re-installing apps after a fresh install?), and restoring
/etc and other hierarchies. If you're sharing the installation over the Internet, this has the advantage that you only need to share a few megabytes, not a few gigabytes (the rest is downloaded from Debian/Raspbian's servers).