Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
558 views
in Technique[技术] by (71.8m points)

ssh with command....Plus the shell

I'd like a command that ssh'es into a machine, runs a command (cd or execute a script or su), and then gives me the shell. Passing a command to ssh seems to always exit.

Some examples of what I'm looking for: 'ssh me@machine1 "./executeMyScript && cd /developmentDirectory"' and then it gives me my shell back.

The reasons I want to do this is because I'm using mrxvt (tabbed x terms) which allows me to define commands for all of my tabs to execute on startup. I'd like to have a few ssh connections to the same machine but have them do different things after sshing.

-Rob

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Variation on the other answers really, use the -t option of ssh to force pseudo-tty allocation:

ssh -t me@machine ./executeMyScript '&&' bash -i

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...