Ssh not supporting sudo and sqlplus commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ssh not supporting sudo and sqlplus commands
# 1  
Old 04-02-2013
Ssh not supporting sudo and sqlplus commands

Hi Guys ,

I was facing an issue some thing like , I have to connect remote machine and should execute few commands over there , I am able to run some simple commands , but below commands are throws error like not found.
Code:
eg : sudo su - username  and sqlplus user/pwd@db , srvrmgr commands etc

ssh command I used here
Code:
ssh -n user@remote host "cd xx/yy/z; pwd; sudo su - username ;sqlplus user/pwd@db; srvrmgr ;"

fyi I tried to run with separate script which I keep in remote machine , but no luck .


Please suggest/help me if any other ways to resolve this issue.

Regards
Chandini

Last edited by Franklin52; 04-02-2013 at 08:46 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 04-02-2013
Try the command
Code:
sudo /bin/su - username


Last edited by Franklin52; 04-02-2013 at 08:47 AM.. Reason: Please use code tags
This User Gave Thanks to Anamica For This Post:
# 3  
Old 04-02-2013
It will be better if you can post the errors.
Doesn't sudo su - username need a password?

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 4  
Old 04-04-2013
Error showing

Hi Anamika , It's not working
I tried with sudo /bin/su - username from remote machine ..but showing error same

bash: sudo: command not found



# 5  
Old 04-04-2013
Looks like the PATH env variable is not available. Log into the remote host and see the output of which sudo and then try using sudo with absolute path in your ssh command.

--ahamed
# 6  
Old 04-04-2013
Quote:
see the output of which sudo and
"which" depends on the PATH, so that won't work, if sudo is not in the PATH.

Check if sudo is installed, using whatever package manager you have.

Or try "find / -name sudo" or "find /usr -name sudo".
# 7  
Old 04-04-2013
You will need to set up the profile of the user account you are ssh connecting with initially so that the PATH includes when the sudo command is, or you could fully qualify it in your command.

I would suggest that this has it's own problems:-
Quote:
Code:
ssh -n user@remote host "cd xx/yy/z; pwd; sudo su - username ;sqlplus user/pwd@db; srvrmgr ;"

The section that has the sudo su - username in it is just that. It will switch user and sit at a prompt. If you want to run sqlplpus or whatever, you need to supply that as arguments, such as:-
Code:
ssh -n user@remote host "cd xx/yy/z; pwd; sudo su - username \"sqlplus user/pwd@db\""

I have highlighted in green the escaped quotes. They need to be escaped because they are within the quoted command that the ssh is sending.


I hope that this helps
Robin
Liverpool/Blackburn
UK
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sqlplus not working through ssh

Hi Gurus, I was trying to execute sqlplus command remotely like ssh -q IP venkat@"which sqlplus" am getting error as which: no sqlplus in (/usr/local/bin:/bin:/usr/bin) if i connect manually and executing which sqlplus it working fine. Please help to fix the issue. Regard's Venky (7 Replies)
Discussion started by: venky.b5
7 Replies

2. Shell Programming and Scripting

Ssh does not support sqlplus and sudo -i?

Hey everybody, currently I am having an issue that I need to open an ssh session to a remote host, once on the remote host I need to use sudo and then execute sqlplus. Once the sqlplus call is open I need to execute one command while the sqlplus is active. For example show sga. I already got so... (3 Replies)
Discussion started by: h1kelds
3 Replies

3. Shell Programming and Scripting

How to automatically run commands after SSH and SUDO not working?

I'm working on a script to SSH and SUDO as (sap user sidadm) then automatically run commands that the sidadm user can run such as R3trans -v, tp, etc.. I can SSH without password and SUDO.. but the commands don't run after I SSH and SUDO to the sidadm user...here is the commands that I've... (2 Replies)
Discussion started by: icemanj
2 Replies

4. UNIX for Advanced & Expert Users

sudo: blocking specific commands

Hello all, I manage some HP-UX 11.31 servers. I have some users that have sudo access. All of them belong to the 'sudoers' user group. Right now, sudo is configured as wide open: %sudoers ALL=(ALL) ALL We are using sudo mostly for auditing purposes - when a user wants to run a... (9 Replies)
Discussion started by: lupin..the..3rd
9 Replies

5. Programming

Using Commands over SSH using Sudo

Is there a way to transfer my sudo password via ssh so that I can copy files remotely and pass them locally, so: cat sudo-passwd-file|ssh -t user@10.7.0.180 'sudo find / -depth|cpio -oacv|gzip' > /path/to/dir/file.cpio.gz I am in the process of a creating a script. Everytime I try and just... (16 Replies)
Discussion started by: metallica1973
16 Replies

6. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

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

sudo commands list

Hi, Can you please give me a list of commands executed through 'sudo' command, thank you. (1 Reply)
Discussion started by: Dev_Dev
1 Replies

8. Shell Programming and Scripting

could not send commands SSH session with Net::SSH::Expect

I am using Net::SSH::Expect to connect to the device(iLO) with SSH. After the $ssh->login() I'm able to view the prompt, but not able to send any coommands. With the putty I can connect to the device and execute the commands without any issues. Here is the sample script my $ssh =... (0 Replies)
Discussion started by: hansini
0 Replies

9. AIX

how can i install sqlplus and execute some sql commands

hi everybody, i am Talip, a begginner at unix based systems and i have a problem (actually, we may think myself as the problem, in this situation). i am not sure if this is the correct platform for my questions. if it is not please forgive me about this inappropriate mail. what i have: *... (2 Replies)
Discussion started by: talipk
2 Replies

10. UNIX for Advanced & Expert Users

Logging all commands after a sudo su-

Hi there, It might seem tricky, I confess. We use sudo to allow people to initiate priviledged commands (but not all commands) on our Unix systems. To by pass this, some people initiate the sudo su - command ; The main issue is to 'know' what those people do when they gain root access.... (4 Replies)
Discussion started by: linuxmtl
4 Replies
Login or Register to Ask a Question