As an example of how it may be done. Here's the upstart init script I use on Ubuntu for cgminer. It will start the miner upon booting regardless of any ssh session/login (user name here was "ubuntu" since this install came from a livecd, change to suit).
/etc/init/miner.conf
description "Start BTC Mining"
start on runlevel [2345]
stop on runlevel [016]
kill timeout 30
script
sleep 15
cd /home/ubuntu
exec /usr/bin/screen -dmS Miner su -c /usr/local/bin/startcg ubuntu
end script
And my simple startcg script handles environment and starting cgminer.
/usr/local/bin/startcg (remember to chmod +x)
#!/bin/bash
export AMDAPPSDKROOT=/home/ubuntu/AMD-APP-SDK-v2.4-lnx32/
export LD_LIBRARY_PATH=${AMDAPPSDKROOT}lib/x86:${LD_LIBRARY_PATH}
export DISPLAY=:0
cgminer 2>>/var/log/cgminer.log
(you'll note I rely on the cgminer.conf for all options)
When you login with ssh you can type,
sudo screen -r
to re-attach to the cgminer screen. And Ctrl-A Ctrl-D to detach again.
I make an alias so I have less to type. eg.
alias mm='sudo screen -r'
put that in my .bashrc file so it gets loaded at login.
Now just mm attaches me to the cgminer screen.