Re: Commands via SSH

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2004-12-28 at 09:56 -0500, Ryan D'Baisse wrote:
> I have found a ton of articles describing how to execute commands
> after logging in through SSH.  However, I need to be able to execute a
> command and HAVE IT CONTINUE RUNNING after I disconnect from the box.
> 
> Anyone got a link or a quick 1-2-3 explanation of what I'm missing?


Hi Ryan,

If you're using SSH with public keys then you should switch
(temporarily!) to passwd-based authentication if you'd like to spawn
background processes and have them continue running on a remote host
after your SSH session ends.  For instance:

 local:  bash
 local:  unset SSH_AGENT_PID SSH_AUTH_SOCK SSH_ASKPASS
 local:  ssh $REMOTE
 <-- enter passwd
 remote:  screen bash
 remote:  ...execute commands inside the screen-ed shell...
 remote:  ^A^d  # exit screen but leave it running
 remote:  exit
 local:  exit

At this point you now have a screen-ed process running on $REMOTE and
you can use the more convenient ssh with public keys to connect and use
it:

 local:  ssh $REMOTE
 remote:  screen -r
 remote:  ...commands...

without having to worry about ssh sessions expiring after you
disconnect.

Ed

-- 
Edward H. Hill III, PhD
office:  MIT Dept. of EAPS;  Rm 54-1424;  77 Massachusetts Ave.
             Cambridge, MA 02139-4307
emails:  eh3@xxxxxxx                ed@xxxxxxx
URLs:    http://web.mit.edu/eh3/    http://eh3.com/
phone:   617-253-0098
fax:     617-253-4464


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux