Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using SSH to launch new terminal and run a command

0 views
Skip to first unread message

pra...@gmail.com

unread,
Mar 21, 2007, 2:43:36 PM3/21/07
to
I'm trying to use ssh to start a new shell (either the same terminal
or in a new one) and have it run a command and stay around.
Specifically, I want to ssh into a shared account (my public key is in
the shared account's authorized keys file) and source my own aliases
file and leave the shell open to work in (Note: I cannot put the
source command into the shared account's cshrc file because many
people use this account and don't want my aliases). I've tried
several things:

> ssh -l shared_account source ~mpratt/.aliases

This just exits right away.

> ssh -X -l shared_account dtterm -e source ~mpratt/.aliases
> ssh -Xf -l shared_account dtterm -e source ~mpratt/.aliases
> ssh -Xtf -l shared_account dtterm -e source ~mpratt/.aliases
> ssh -Xtfn -l shared_account dtterm -e source ~mpratt/.aliases

Any combination of Xntf options seems to popup the new terminal and
then close it. One of the commands actually reports an error from the
source command saying it can't find ~mpratt/.aliases (which is weird
since I source it in my own .cshrc without problems).

Any suggestions?

Thanks,

Mike

Kalyan Manchikanti

unread,
Mar 21, 2007, 3:05:00 PM3/21/07
to

How about putting the aliases file in the home directory of the
shared_account or sourcing it from the dotfiles of the shared_account
and doing a "dtterm -e ssh -X -l shared_account localhost &"

Bernd Haug

unread,
Mar 21, 2007, 6:22:51 PM3/21/07
to
pra...@gmail.com <pra...@gmail.com> wrote:
> Any suggestions?

Might ssh -t bhn 'other-command; $SHELL' be what you're looking for?
Of course, other-command can't directly affect the environment in the
shell.

Also, the options may be OpenSSH specific; that shouldn't be a problem
with Solaris, though.

lg, Bernd

Paul Kimoto

unread,
Mar 22, 2007, 12:02:51 AM3/22/07
to
On 2007-03-21, pra...@gmail.com <pra...@gmail.com> wrote:
> I'm trying to use ssh to start a new shell (either the same terminal
> or in a new one) and have it run a command and stay around.
> Specifically, I want to ssh into a shared account (my public key is in
> the shared account's authorized keys file) and source my own aliases
> file and leave the shell open to work in (Note: I cannot put the
> source command into the shared account's cshrc file because many
> people use this account and don't want my aliases).

>> ssh -X -l shared_account dtterm -e source ~mpratt/.aliases


>> ssh -Xf -l shared_account dtterm -e source ~mpratt/.aliases
>> ssh -Xtf -l shared_account dtterm -e source ~mpratt/.aliases
>> ssh -Xtfn -l shared_account dtterm -e source ~mpratt/.aliases

Can this work? There is no executable program "source" that does what you
want. What you have in mind is some functionality provided by the shell.

> Any combination of Xntf options seems to popup the new terminal and
> then close it.

For newer versions of openssh you may need to use "-Y" ("Enables trusted
X11 forwarding") rather than "-X".

> Any suggestions?

I don't know of any way to get an interactive shell to use a startup file
with a different name.

Perhaps you should start using some other shell, bash, zsh, etc., or even
tcsh/csh if all your colleagues use the other (i.e., csh/tcsh); then you
can put whatever you like in that shell's startup file and start it up as
your target program ("ssh ... dtterm -e othershell").

--
Paul Kimoto
This message was originally posted on Usenet in plain text. Any images,
hyperlinks, or the like shown here have been added without my consent,
and may be a violation of international copyright law.

Paul Kimoto

unread,
Mar 22, 2007, 10:53:38 AM3/22/07
to
On 2007-03-22, Paul Kimoto <kim...@lightlink.com> wrote:
> On 2007-03-21, pra...@gmail.com <pra...@gmail.com> wrote:
>> I want to ssh into a shared account (my public key is in
>> the shared account's authorized keys file) and source my own aliases
>> file and leave the shell open to work in (Note: I cannot put the
>> source command into the shared account's cshrc file because many
>> people use this account and don't want my aliases).

> I don't know of any way to get an interactive shell to use a startup file
> with a different name

... but you could accomplish the goal along the following lines:

(1) Put a line in the shared cshrc that says something like

test -e "$extracshrccommands" && source "$extracshrccommands"

(2) Write (and make executable) a little script like

#!/bin/csh
setenv extracshrccommands ~mpratt/.aliases
exec /bin/csh

(3) Run ssh with this script as the program to be run ("ssh ... dtterm -e
/path/to/this/script").

(Please check syntax, as I switched away from csh a long time ago.)

pra...@gmail.com

unread,
Mar 26, 2007, 10:36:34 AM3/26/07
to

Thanks for all the responses. Unfortunately I am kind of limited in
my options for the main reason that I cannot modify the .cshrc file
for shared_account (or any of its file: it's shared by all our users
and modifying it is frowned upon and will get me a slap on the wrist).

I also cannot change shells, so I'm stuck with tcsh. And I had said
source originally, but perhaps I'd have better luck with the "."
command?

Mike

Steve Pointer

unread,
Mar 26, 2007, 11:17:19 AM3/26/07
to

>
> Thanks for all the responses. Unfortunately I am kind of limited in
> my options for the main reason that I cannot modify the .cshrc file
> for shared_account (or any of its file: it's shared by all our users
> and modifying it is frowned upon and will get me a slap on the wrist).
>
> I also cannot change shells, so I'm stuck with tcsh. And I had said
> source originally, but perhaps I'd have better luck with the "."
> command?
>
> Mike
>

I must be missing the difficulty with this one but

ssh -l <shared-account> <host> bash --rcfile
<custombashrcwithaliasesandprogramtoexeconlogin>

Would this not do what you want?

--
Steve Pointer

0 new messages