Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Trying to ssh as another user and cd to directory

$
0
0
I can ssh to another directory by doing the following:
for server in server1; do ssh -t $server1 "cd /tmp; 'ls'";done

However, if I try to do it as another user it fails:
I have tried:


for server in server1
do
dir=$(su - nbadaccount -c "ssh $server `cd '/tmp/TSTCON'` " )
pwd
done

for server in server1; do su nbadaccount -c "ssh -t $server "cd /tmp 'ls'"";done

for server in server1; do su nbadaccount -c ssh -t $server "cd /tmp; 'ls'";done

and a variety of other methods. The most I can get it to do is to ssh to the server but it never changes directories. Does anybody have any idea how to do this? Thanks in advance for any help.

Viewing all articles
Browse latest Browse all 16232

Latest Images

Trending Articles



Latest Images