01-27-2011
I don't think you understand what | means. Do you really want to channel the text output of the su command into the id command? id reads no input, it just prints!
This will log you in as ldaprole, run something, then give you a prompt: $ ssh -t localhost 'sudo su - ldaprole -c "id ; exec bash"'
The -c tells su to run the given command after it. We're telling it to run id, then run a shell... Running a shell is crucial because without it, ssh and su will both consider themselves out of input and return without waiting.
Substitute your shell of choice for bash. Absolute paths preferred.
Last edited by Corona688; 01-27-2011 at 03:01 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hello,
Can you config sudo to use the passphrase in the user ssh-key instead of the one in the passwd?
Some users do not have local passwords on the system and instead of adding the NOPASSWD in sudoers I would like the solution I asked about above.
Thx Jocke (3 Replies)
Discussion started by: jOOc
3 Replies
2. UNIX for Advanced & Expert Users
Hi,
I would like to know how i can perform a task, while performing ssh, sudo and command at the same time.
What I generally do is I ssh to the server, where i created private and public, so it does not prompt me for password all the time. Then i need to run "sudo su - ldaprole" to get into... (9 Replies)
Discussion started by: john_prince
9 Replies
3. Shell Programming and Scripting
Hi Gurus,
I have small issue...
I used to pass the passwd for sudo commands like below,
gzcat ~/passwd.gz | sudo su - <villin> >> eof
------
-----
------
eof
And it was able to login into "villin" sudo account successfully. But now, I'm using the same in another script for the... (2 Replies)
Discussion started by: raghu.iv85
2 Replies
4. HP-UX
why I can login by telnet using root account
but when i use login by ssh using root account
it is not successful ,is it different password
i am sure ssh service is started (2 Replies)
Discussion started by: alert0919
2 Replies
5. UNIX for Dummies Questions & Answers
I logged in through ssh, but can't re-login as root.
sudo login
Arch login: root
Password:
Login incorrect
Arch login:
But I am sure my password is right. Why?
But on local tty1, this works. (2 Replies)
Discussion started by: vistastar
2 Replies
6. Shell Programming and Scripting
I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this:
#!/bin/bash
rsync /path/on/local/machine/ foo.com:path/on/remote/machine/
ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies
7. UNIX for Dummies Questions & Answers
Hi All,
I am trying use the below su command to execute a shell script using different user.
Caould some one please help me out as to how to pass the pass the password when prompted or is there any way to execute the shell script using other user.
I have had look at the other posts in forum... (1 Reply)
Discussion started by: abhi_n123
1 Replies
8. Shell Programming and Scripting
Hello All ,
Hope everyone is doing great !
can someone help me for the below problem statement with the help of a script .
1. I am having couple of Linux Servers
a. I need to login and need to do a sudo
b. need to give a user id , which will take to user directory`s homedirectory... (1 Reply)
Discussion started by: radha254
1 Replies
9. Cybersecurity
I'm confused in the configuration of sudoers for one group of users.
The users need to execute a app from a remote machine, in this local machine they want me to allow ssh for them using sudo
for eg. sudo -u admin ssh -X euadmin@<IP address of remote> <remote script which opens a gui>
It... (1 Reply)
Discussion started by: anandk
1 Replies
10. UNIX for Beginners Questions & Answers
Hi,
I am planning to automate a deployment process and the below are the steps
Connect from windows to Unix server
Login with user name : admin and password
After logging in , switch user to root to get additional privileges
Perform actions on files and directories post switching to... (3 Replies)
Discussion started by: venkidhadha
3 Replies