09-25-2017
It would be better, if you actually know the credentials of the root user, to connect and set up SSH keys to achieve this rather than trying to get round it with expect.
You have to decide on the target server if root is allowed to login, and this may be preventing you, and for a good reason too.
Clearly this is a dummy set up, so what are you actually trying to achieve? There are probably better ways rather than trying to crack in and shovel in direct commands. Think - If you can do it then so can someone else with different motives.
If you can describe what you need then we can probably help you find a much neater way to do this.
Kind regards,
Robin
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi
i am having two servers one is local and remote(FTP)server.from local server i have to connect to remote server and execute a shell script
i want to run a shell script(remote location) from my local server
i am having some knowledge on ftp but i am not getting the result .please give ... (2 Replies)
Discussion started by: srivsn
2 Replies
2. Shell Programming and Scripting
Hi,
Im creating a script that is supposed to run commands on remote server using sftp.
My script is as below:
#!/bin/ksh
sftp remote_server
mypassword
cd /u08/mydir/allfiles
mget *
..
But this is what I got when I runned the script:
Connecting to remote server...... (3 Replies)
Discussion started by: luna_soleil
3 Replies
3. Shell Programming and Scripting
Hi, I have googled for quite some time and couldn't able to get what exactly I am looking for.. My query is "how to stop a shell script which is running inside a remote server, using a script"??? can any one give some suggestions to sort this out. (1 Reply)
Discussion started by: mannepalli
1 Replies
4. Shell Programming and Scripting
Hi,
I have a script that runs for an hour.
Have to run it on remote server and need the output it produces on the remote server to decide for failure or success.
I run it through a Autosys Job which logs the outputs, both 1 & 2.
I use the commands
1) rsh <SERVER> 'nohup /tmp/xyz.ksh &'
2)... (5 Replies)
Discussion started by: aster007
5 Replies
5. Programming
Hi All,
I am using a expect script to run a shell script on remote server, the code is as follows. But the problem is that it executes only first command, and hangs it doesn't run the next commands.
spawn ssh $uid@$host
expect "password:"
send "$password\r"
expect "*\r"
send... (2 Replies)
Discussion started by: yashwanthsn
2 Replies
6. Shell Programming and Scripting
I am unable to run the below script against a remote server due to syntax error (then unexpected), but i am able to run it locally. Am i executing it correctly or is there any other way to execute it.
ssh username@servernname ksh -s < scriptname
#!/bin/ksh
function record
{
((end =... (5 Replies)
Discussion started by: NarayanaPrakash
5 Replies
7. Shell Programming and Scripting
I need to run a local shell script on a remote machine. I am able to achieve that by executing the command
> ssh -qtt user@host < test.sh
However, when I try to pass arguments to test.sh it fails.
Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies
8. Shell Programming and Scripting
Hi all,
i need to run a shell script on remote server. I have created file .bat file in windows server with following code,
c:\Users\Desktop\putty.exe -ssh -pw password user@server ./script.sh
i need to run the script.sh in my remote server
Above command is not working, any... (4 Replies)
Discussion started by: rammm
4 Replies
9. Solaris
Hi,
I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script.
Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies
10. Shell Programming and Scripting
Hi guys,
So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies
SU(1) BSD General Commands Manual SU(1)
NAME
su -- substitute user identity
SYNOPSIS
su [-] [-flm] [login [args]]
DESCRIPTION
The su utility requests appropriate user credentials via PAM and switches to that user ID (the default user is the superuser). A shell is
then executed.
PAM is used to set the policy su(1) will use. In particular, by default only users in the ``admin'' or ``wheel'' groups can switch to UID 0
(``root''). This group requirement may be changed by modifying the ``pam_group'' section of /etc/pam.d/su. See pam_group(8) for details on
how to modify this setting.
By default, the environment is unmodified with the exception of USER, HOME, and SHELL. HOME and SHELL are set to the target login's default
values. USER is set to the target login, unless the target login has a user ID of 0, in which case it is unmodified. The invoked shell is
the one belonging to the target login. This is the traditional behavior of su.
The options are as follows:
-f If the invoked shell is csh(1), this option prevents it from reading the ``.cshrc'' file.
-l Simulate a full login. The environment is discarded except for HOME, SHELL, PATH, TERM, and USER. HOME and SHELL are modified as
above. USER is set to the target login. PATH is set to ``/bin:/usr/bin''. TERM is imported from your current environment. The
invoked shell is the target login's, and su will change directory to the target login's home directory.
- (no letter) The same as -l.
-m Leave the environment unmodified. The invoked shell is your login shell, and no directory changes are made. As a security precau-
tion, if the target user's shell is a non-standard shell (as defined by getusershell(3)) and the caller's real uid is non-zero, su
will fail.
The -l (or -) and -m options are mutually exclusive; the last one specified overrides any previous ones.
If the optional args are provided on the command line, they are passed to the login shell of the target login. Note that all command line
arguments before the target login name are processed by su itself, everything after the target login name gets passed to the login shell.
By default (unless the prompt is reset by a startup file) the super-user prompt is set to ``#'' to remind one of its awesome power.
ENVIRONMENT
Environment variables used by su:
HOME Default home directory of real user ID unless modified as specified above.
PATH Default search path of real user ID unless modified as specified above.
TERM Provides terminal type which may be retained for the substituted user ID.
USER The user ID is always the effective ID (the target user ID) after an su unless the user ID is 0 (root).
FILES
/etc/pam.d/su PAM configuration for su.
EXAMPLES
su man -c catman
Runs the command catman as user man. You will be asked for man's password unless your real UID is 0.
su man -c 'catman /usr/share/man /usr/local/man'
Same as above, but the target command consists of more than a single word and hence is quoted for use with the -c option being passed
to the shell. (Most shells expect the argument to -c to be a single word).
su -l foo
Simulate a login for user foo.
su - foo
Same as above.
su - Simulate a login for root.
SEE ALSO
csh(1), sh(1), group(5), passwd(5), environ(7), pam_group(8)
HISTORY
A su command appeared in Version 1 AT&T UNIX.
BSD
September 13, 2006 BSD