Is it possible to install a .pkg using a terminal ? (I wanted to install an app through ssh).
The installer command is used to install Mac OS X installer packages to a specified domain or volume. The installer command installs a single package per invocation, which is specified with the -package parameter ( -pkg is accepted as a synonym). It may be either a single package or a metapackage. In the case of the metapackage, the packages which are part of the default install will be installed unless disqualified by a package's check tool(s).
man installer for the full functionality. Often
sudo installer -pkg /path/to/package.pkg -target /
is all that's needed.
.pkg files from the current folder to
for f in *.pkg ; do sudo installer -verbose -pkg "$f" -target / done
As an alternative you can install the packages to your home folder with
-target ~. They will end up in
/Users/<your_account>/Applications unless a specific path is predefined in the installer.
If you need to see what exactly a pkg installer script contains and what pre- and post-install scripts will be run then check out SuspiciousPackage (freeware), and use quick preview from Finder when a
.pkgfile is selected. Pressing spacebar in Finder with the selected file should work too.