#!/bin/bash function show_uptime() { uptime } PEM_FILE=some/path ssh -i ${PEM_FILE} $1 "$(typeset -f show_uptime); show_uptime"