I'd like to set up some logins to various places around my LAN which not only ssh to the relevant place but also do a cd to a specific directory.
Can anyone suggest a way to do this? By default if you give a command to ssh at the end of the line then it executes that command and then closes the connection - it only keeps the connection open if there is no command at the end. In addition doing a cd is even a bit more difficult because it's no use at all to execute it in a sub-shell.
On 01 Nov 12:04, Chris G wrote:
I'd like to set up some logins to various places around my LAN which not only ssh to the relevant place but also do a cd to a specific directory.
OK - so is this key dependant or user dependant?
Can anyone suggest a way to do this? By default if you give a command to ssh at the end of the line then it executes that command and then closes the connection - it only keeps the connection open if there is no command at the end. In addition doing a cd is even a bit more difficult because it's no use at all to execute it in a sub-shell.
Well, you could always create multiple users with the same uid/gid and make it so that their $HOME is set to the directory you want it to go to, that'd be a fairly typical workaround.
On Mon, Nov 01, 2010 at 12:20:04PM +0000, Brett Parker wrote:
On 01 Nov 12:04, Chris G wrote:
I'd like to set up some logins to various places around my LAN which not only ssh to the relevant place but also do a cd to a specific directory.
OK - so is this key dependant or user dependant?
Neither.
Can anyone suggest a way to do this? By default if you give a command to ssh at the end of the line then it executes that command and then closes the connection - it only keeps the connection open if there is no command at the end. In addition doing a cd is even a bit more difficult because it's no use at all to execute it in a sub-shell.
Well, you could always create multiple users with the same uid/gid and make it so that their $HOME is set to the directory you want it to go to, that'd be a fairly typical workaround.
What I actually want to do at this particular moment is log onto my web server as www-data and change to different directories according to what I want to edit, e.g. :-
'info' - logs me on to the server as www-data and takes me to /var/www/info 'boat' - logs me on to the server as www-data and takes me to /var/www/boat etc.
Yes, I know it's rather trivial, but I find this sort of thing very useful.
On 1 November 2010 14:41, Chris G cl@isbd.net wrote:
What I actually want to do at this particular moment is log onto my web server as www-data and change to different directories according to what I want to edit, e.g. :-
'info' - logs me on to the server as www-data and takes me to /var/www/info 'boat' - logs me on to the server as www-data and takes me to /var/www/boat etc.
Yes, I know it's rather trivial, but I find this sort of thing very useful.
Sounds like making a mountain out of a mole hill to me, when all you have to do upon initial log in is 'cd /to/the/dir' thats all your going to cut out?
I can't see you doing;
www-data@machine info
www-data@machine boat
as you can't parse an argument to an interactive session? I.e. AFAIK you either 'ssh user@machine' and have an interactive session or parse arguments that are executed and thats it, you can't parse an argument and have an interactive session I don't believe.
On Mon, Nov 01, 2010 at 03:06:21PM +0000, James Bensley wrote:
On 1 November 2010 14:41, Chris G cl@isbd.net wrote:
What I actually want to do at this particular moment is log onto my web server as www-data and change to different directories according to what I want to edit, e.g. :-
'info' - logs me on to the server as www-data and takes me to /var/www/info 'boat' - logs me on to the server as www-data and takes me to /var/www/boat etc.
Yes, I know it's rather trivial, but I find this sort of thing very useful.
Sounds like making a mountain out of a mole hill to me, when all you have to do upon initial log in is 'cd /to/the/dir' thats all your going to cut out?
Yes, true enough, I did say it was "rather trivial". It's slightly more than I said actually, I want to do "cd /var/www/info/data/pages" for the 'info' login and "cd /var/www/boat/data/pages" for the boat login.
I can't see you doing;
www-data@machine info
www-data@machine boat
as you can't parse an argument to an interactive session? I.e. AFAIK you either 'ssh user@machine' and have an interactive session or parse arguments that are executed and thats it, you can't parse an argument and have an interactive session I don't believe.
Yes, that's how I understand it too.
I have come up with a possible solution though:-
ssh -X -f -l www-data mws <script>
Where <script> executes a GUI application that runs in the required directory, in my case an editor. E.g. I do:-
ssh -X -f -l www-data mws ~/bin/info
and ~/bin/info on the target system is simply:-
cd /var/www/info/data/pages xvile
(xvile is a GUI editor, like gvim) Wierdly ~/bin/info is /home/chris/bin/info on the target system, not in www-data's bin directory.
One could probably make it more general by executing a terminal application but as the object of the exercise for me is to make it simple to edit specific virtual host web pages firing up the editor directly in the right place is what I want.
On 01 Nov 15:45, Chris G wrote:
On Mon, Nov 01, 2010 at 03:06:21PM +0000, James Bensley wrote:
On 1 November 2010 14:41, Chris G cl@isbd.net wrote:
What I actually want to do at this particular moment is log onto my web server as www-data and change to different directories according to what I want to edit, e.g. :-
'info' - logs me on to the server as www-data and takes me to /var/www/info 'boat' - logs me on to the server as www-data and takes me to /var/www/boat etc.
Yes, I know it's rather trivial, but I find this sort of thing very useful.
Sounds like making a mountain out of a mole hill to me, when all you have to do upon initial log in is 'cd /to/the/dir' thats all your going to cut out?
Yes, true enough, I did say it was "rather trivial". It's slightly more than I said actually, I want to do "cd /var/www/info/data/pages" for the 'info' login and "cd /var/www/boat/data/pages" for the boat login.
I can't see you doing;
www-data@machine info
www-data@machine boat
as you can't parse an argument to an interactive session? I.e. AFAIK you either 'ssh user@machine' and have an interactive session or parse arguments that are executed and thats it, you can't parse an argument and have an interactive session I don't believe.
Yes, that's how I understand it too.
I have come up with a possible solution though:-
ssh -X -f -l www-data mws <script>
How about: ssh www-data@machine "cd /var/www/info/data/pages && exec bash -i"
Which certainly seems to work.
Cheers,
On Mon, Nov 01, 2010 at 05:00:40PM +0000, Brett Parker wrote:
On 01 Nov 15:45, Chris G wrote:
On Mon, Nov 01, 2010 at 03:06:21PM +0000, James Bensley wrote:
On 1 November 2010 14:41, Chris G cl@isbd.net wrote:
What I actually want to do at this particular moment is log onto my web server as www-data and change to different directories according to what I want to edit, e.g. :-
'info' - logs me on to the server as www-data and takes me to /var/www/info 'boat' - logs me on to the server as www-data and takes me to /var/www/boat etc.
Yes, I know it's rather trivial, but I find this sort of thing very useful.
Sounds like making a mountain out of a mole hill to me, when all you have to do upon initial log in is 'cd /to/the/dir' thats all your going to cut out?
Yes, true enough, I did say it was "rather trivial". It's slightly more than I said actually, I want to do "cd /var/www/info/data/pages" for the 'info' login and "cd /var/www/boat/data/pages" for the boat login.
I can't see you doing;
www-data@machine info
www-data@machine boat
as you can't parse an argument to an interactive session? I.e. AFAIK you either 'ssh user@machine' and have an interactive session or parse arguments that are executed and thats it, you can't parse an argument and have an interactive session I don't believe.
Yes, that's how I understand it too.
I have come up with a possible solution though:-
ssh -X -f -l www-data mws <script>
How about: ssh www-data@machine "cd /var/www/info/data/pages && exec bash -i"
Which certainly seems to work.
Yes, that works too of course as ssh waits for bash to exit, thank you!
(Not infront of SSH right now so OTOMH): Can't you do something like:
ssh user@machine 'cd /a/directory; touch my_file'
On Mon, Nov 01, 2010 at 12:24:10PM +0000, James Bensley wrote:
(Not infront of SSH right now so OTOMH): Can't you do something like:
ssh user@machine 'cd /a/directory; touch my_file'
No, if you do the above ssh connects to user@machine, does the cd, executes the touch and then disconnects again leaving you back at your original machine prompt. E.g. :-
chris$ ssh mws 'cd tmp; touch fred' chris$
... and it's created a file fred in ~/tmp on the machine mws.
Please excuse my ignorance; it has been awhile, but does SSH not log you into the directory that is set as the user's default directory? Could you not setup users for each of these directories and log into them dependently? or do you need a user to be able to login with their user name each time for every directory?
On Mon, Nov 1, 2010 at 12:04 PM, Chris G cl@isbd.net wrote:
I'd like to set up some logins to various places around my LAN which not only ssh to the relevant place but also do a cd to a specific directory.
Can anyone suggest a way to do this? By default if you give a command to ssh at the end of the line then it executes that command and then closes the connection - it only keeps the connection open if there is no command at the end. In addition doing a cd is even a bit more difficult because it's no use at all to execute it in a sub-shell.
-- Chris Green
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
On Mon, Nov 01, 2010 at 12:25:53PM +0000, Alex Scotton wrote:
On Mon, Nov 1, 2010 at 12:04 PM, Chris G cl@isbd.net wrote:
I'd like to set up some logins to various places around my LAN which not only ssh to the relevant place but also do a cd to a specific directory.
Can anyone suggest a way to do this? By default if you give a command to ssh at the end of the line then it executes that command and then closes the connection - it only keeps the connection open if there is no command at the end. In addition doing a cd is even a bit more difficult because it's no use at all to execute it in a sub-shell.
Please excuse my ignorance; it has been awhile, but does SSH not log you into the directory that is set as the user's default directory? Could you not setup users for each of these directories and log into them dependently? or do you need a user to be able to login with their user name each time for every directory?
Yes, it does, but I want to log on as a specific user (www-data) and get to different places so I can go straight to editing different virtual web sites.