Old 12th August 2009, 20:22
ramesh_rncbe ramesh_rncbe is offline
Junior Member
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Automate SCP...

I am trying to move files from local server to remote unix server...
for that I am using SCP to achieve this....

I have written script to achieve this but with password prompt....
Login username on remote is tester1...
After login i will do sudo to login as the application user...
thru sudo command...
Eg : Sudo /usr/local/bin/mcfs
mcfs -> Application user....
After doing scp..if i try ll command...
it shows the UID as tester1... but we need it as mcfs application user.. so that developers can access the file without any problem...

Above task is achieved by using shell script but only as tester1 not with sudo user...

Any help would be really apprecaited...
Reply With Quote
Sponsored Links
Old 12th August 2009, 22:05
id10t id10t is offline
Senior Member
Join Date: Nov 2008
Posts: 242
Thanks: 2
Thanked 22 Times in 22 Posts

You need to scp the files as the MFC user

scp somefile mfcuser@remotebox:/path/to/copy/file/to

You could also set it up wtih passwordless SSH keys to automate copying so you don't have to enter a pw
Reply With Quote
Old 13th August 2009, 13:04
ramesh_rncbe ramesh_rncbe is offline
Junior Member
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for your reply... please look at the script and help me on this....

# INI_FILE is the input file that's where we have the host , Remote host and # source and destination directories mentioned.
if [ -f ${INI_FILE} ]
#Run the INI_FILE
echo "Running INI FILE"
echo "${INI_FILE}"
echo "${HOST}"
echo "${D_HOST}"

echo " \n Environment file <PATH.INI> not present. Please check. \n"
exit 1

perm() {

cd ${SRC_DIR}
chmod -R 775 *


File_Transfer() {

cd ${SRC_DIR}
cat /home/pvcs/Ram/scp1.sh | ssh ${USER}@${D_HOST}
# scp1.sh is sudo user file.. where the below mentioned command will # be executed....
#sudo /usr/local/sbin/mcds

# sudo /usr/sbin/sudo/mcds
scp -p ${SRC_DIR}/*.sh ${USER1}@${D_HOST}:${DES_DIR}


Can you help me how to add the mfc user in this scripts... i am new to scripting...
Any help would be really helpful...
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automate user signup. Tommahawk Tips/Tricks/Mods 179 26th June 2010 03:47
Automate account creation from website? keyvan General 1 14th May 2009 19:21
Allow SCP but not SSH (How?) Mosquito Server Operation 1 25th October 2008 12:00
scp with password knowram Technical 2 5th March 2007 19:40
ssh chroot works, but no scp for chroot users zokahn HOWTO-Related Questions 5 30th January 2006 10:33

All times are GMT +2. The time now is 13:32.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.