Tuesday, December 22, 2009

How to execute remote bash commands using ssh

"...

ssh -t YOURHOST "bash --rcfile PATH_TO_RCFILE_ON_REMOTE_HOST_HOME_DIR_SHORTCUTS_WORK_FOR_AUTHED_USER"

bash will be executed on the remote host, and bash will execute the specfied RCFILE at startup, and connection will remain open. -t is to have the current terminal forwarded to the ssh session so that you have a real terminal.

You can have some variant on the same kind, still use ssh -t. Like if screen is installed, you can do:

ssh -t YOURHOST screen

..."

Alternative:

"...

ssh YOURHOST bash --rcfile YOUR_RC_FILE -i

But then you don't have a real terminal, and some stuff will not work correctly (like tab auto-completion).

..."

from:

http://www.linuxforums.org/forum/linux-networking/102713-how-execute-remote-shell-commands-via-ssh.html

No comments: