taiko
taiko

Reputation: 448

Listing directory as different user via ssh on remote solaris machine

I'm trying to list the directory on remote solaris machine as a different user, but I always get the list of homedirectory of the user. I'm using

sudo ssh remoteip su - username -c 'ls -al /var/adm'

as a result I see the content of username's home directory

I also tried

sudo ssh username@remoteip 'ls -al /var/adm'

but this doesn't work either (password is asked )as it looks like I only can do ssh with sudo and then change user.

Upvotes: 0

Views: 86

Answers (1)

cachonfinga
cachonfinga

Reputation: 890

Try:

ssh host 'sudo -u username sh " id; ls -l /var/adm"'

If you really need to sudo to run ssh then add sudo to the start of the line. hth.

Upvotes: 1

Related Questions