ssh command in ksh script encounters permission error

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh command in ksh script encounters permission error
# 1  
Old 02-25-2008
ssh command in ksh script encounters permission error

I've created a script and copied it to another server and try to execute it at the same time but I'm getting a permission error.
I'm logged on as root and I gave the file 777 permission when I created it, but I can't run it remotely via ssh command because of permission issue.

Any ideas?

Thanks in advance.

chmod 777 /usr/local/bin/${script_name}
scp /usr/local/bin/${script_name} ${servernames$iy]}://usr/local/bin/
ssh root@${servernames[$iy]} 'cd /usr/local/bin/userid/; ./${script_name}'


Please type the userid

Please type the server name

root@bk02's password:
script2run.ksh 100% 72 0.1KB/s 00:00

root@bk02's password:
ksh: ./: 0403-006 Execute permission denied.
# 2  
Old 02-25-2008
Ack! It's rare that a file needs 777 permissions, especially one that is owned by root. But if you want to keep the permissions, change the scp line to:

scp -p /usr/local/bin/${script_name} ${servernames$iy]}://usr/local/bin/

# 3  
Old 02-25-2008
Permission was set to 700 but I changed it to 777 to make it work and it didn't.
cp -p option didn't work either.
# 4  
Old 02-25-2008
Where in the script are you declaring ${script_name} ?

You didn't post the entire script, but by the message you are getting, it seems that ${script_name} is null and what the ssh command is trying to execute is just ./
BTW, you don't need to cd then execute. Just do
ssh hostname /usr/local/bin/script

Also, your scp command pretends to copy ${script_name} to /usr/local/bin, but your ssh command goes to /usr/local/bin/userid.
# 5  
Old 02-25-2008
Thanks System Shock.
I'll try that.
# 6  
Old 02-25-2008
Thanks System Shock. That worked. You're the man!

Thanks System Shock. That worked. You're an expert!

One more question,

Is there anyway that I can reset user's password using ssh command?
ie. emulate passwd command with a default password of abc123 or even null value?

> ssh server1 pwdadm user1 < /dev/null
> ssh server1 passwd user1 < /dev/null

neither worked for me.. but you know what I mean... I couldn't emulate enter keys.

I know this method is not recommended, but I've got more than 40 servers, and I don't want to login to every server to reset passwords.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to stop a shell script if it encounters a error?

I am writing a bash shell script for GarazLab's "WP EMAIL CRAWLER - AUTO SCRAPER & REAL TIME EXTRACTOR". it contains some commands. I want to stop the shell execution as soon as it encounters an error. how to do it? (8 Replies)
Discussion started by: tahsin352
8 Replies

2. Shell Programming and Scripting

Help with ssh ksh script

Hi, I am trying to figure out a ksh script that i have and i think i found it but not sure. i am having to scp or sftp files from my remote server over 2 others to the destination. i have the rsa keys setup for the servers on my end and the username and password for the final server. ... (3 Replies)
Discussion started by: ksh_beginner
3 Replies

3. Shell Programming and Scripting

ksh script to test max number of parallel ssh connections

hello , I need to check how many parallel ssh connections my server can take the load of. I need to login to different host which i am planning to read from a file and then a write a loop which will do parallel ssh. Please provide suggestion on how i can write script for the same.\ Thank... (1 Reply)
Discussion started by: ABHIKORIA
1 Replies

4. Shell Programming and Scripting

issue on ssh command in ksh shell

Hi guru, I'm making crazy cause an issue on a ksh shell I made. In this shell I want to execute unix command on a remote machine using an ssh connection like ssh user@host 'command'..... The command is very simply, is an ls on a remote directory but it give me an unexpected result. The... (4 Replies)
Discussion started by: leobdj
4 Replies

5. Shell Programming and Scripting

ksh script with Interactive ssh on remote server

HI Unix Gurus, I an stuck in an interesting issue, where I am trying to execute a script on remote server after ssh. The script on remote server is interactive,. Whenever it is called it hangs where it expects input from terminal and I have to terminate it. I have searched through fourm... (12 Replies)
Discussion started by: Jeevanm
12 Replies

6. AIX

SSH Error - Permission denied (publickey,keyboard-interactive)

Hello, I'm trying to setup password less authentication to remote ssh server. I generated the public key and gave it to the vendor and The key is added in the remote machines authorized_keys file. When I try to connect to a remote machine through SFTP username@host I am getting the error... (4 Replies)
Discussion started by: nice_chapp
4 Replies

7. Shell Programming and Scripting

Help with Backup Shell Script 'ksh + awk over ssh'

Hi newbeeeee alarm i want to send a little script over ssh this script mus download a report.tar then rename and move. the report name format is report_<>-10-09-20-11:55:25.tar function remote_cmd_mv { _host=$1 ARCHROOTDIR='/tmp' ... (8 Replies)
Discussion started by: TigerGoods
8 Replies

8. Shell Programming and Scripting

ssh into a shell script (KSH)

Hi all, Just like to ask if it is possible to do the following: 1. Have a shell script that calls ssh username@destinationhost 2. Upon successful verification, we ssh into the destination host and automatically use ksh to run a shell script that resides in the destination host. (Hopefully no... (8 Replies)
Discussion started by: rockysfr
8 Replies

9. UNIX for Advanced & Expert Users

Use of sudoer with ssh login shell script (KSH)

Greetings all, I'm in the midst of writing a login component for a series of shell scripts. What my login script does is this: 1. Prompt for username and read in username 2. Prompt for destination host and read in destination host 3. run ssh username and destination host 4. After user keys... (0 Replies)
Discussion started by: rockysfr
0 Replies

10. Shell Programming and Scripting

Testing ssh connection from KSH script

Hi. I have a kornshell script that runs on a daily basis as a cron job. Part of what the script does is copy the folder contents from another server to the current server (server where KSH script is running). I have a scp command, as follows: scp $REMOTE_HOST:$REMOTE_FILE_DIR/* $TMP_DIR ... (8 Replies)
Discussion started by: dmilks
8 Replies
Login or Register to Ask a Question