LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   scp error : permission denied :(( (https://www.linuxquestions.org/questions/linux-newbie-8/scp-error-permission-denied-850192/)

hiteurecomupf 12-14-2010 11:18 AM

scp error : permission denied :((
 
Hi All ,

I am facing this scp permission denied again and again and am kind of lost of how to solve this. Before to discuss my error i need to write a bit on what context i am facing this error.

I am trying to make one traffic generator IMS Bench SIPp work , which will generate huge amount of traffic. Now in this traffic generator, it will use 2 virtual IP's who will be working as 2 Test Systems (TS1 and TS2). I have one host IP (A) where i have 2 virtual IP's (B,C) alive and running. I can ssh into both of them from host A with command " ssh B -l <username>". IP B is TS1 and IP C is TS2.

Now to prepare this 2 (B,C) Test System's , i need to run one script which is " ./prepare.sh". This script looks like this ,

echo "Preparing TS1 (IP B) ..."
ssh <IP B> "mkdir -p /usr/local/sipp"
scp ims_users_1.inf run_1.sh ../sipp <IP B>:/usr/local/sipp
if [ $? -ne 0 ]; then echo "Error: Failed to prepare TS1"; exit; fi
echo "Preparing TS2 (IP C) ..."
ssh <IP C> "mkdir -p /usr/local/sipp"
scp ims_users_2.inf run_2.sh ../sipp <IP C>:/usr/local/sipp
if [ $? -ne 0 ]; then echo "Error: Failed to prepare TS2"; exit; fi
echo "

When i am running this script i am getting this following error ,

sougata@sougata-desktop:~/ims_bench/ims_bench_0$ ./prepare.sh
Preparing TS1 (ip B) ...
scp: /usr/local/sipp/ims_users_1.inf: Permission denied
scp: /usr/local/sipp/run_1.sh: Permission denied
scp: /usr/local/sipp/sipp: Permission denied
Error: Failed to prepare TS1

Any suggestion please on why this scp error is coming.
I tried doing chmod 777 -R on this folder "ims_bench_0" where all the corresponding files are present such as ims_users_1.inf , run_1.sh etc. But no way can't let this error go away.

With regards ,

Sougata

coexistance 12-14-2010 01:16 PM

Hello hiteurecomupf

First of all, make sure that all the files are allowed to executable:
Code:

chmod +x ~/ims_bench/*
Now try execute as you have done.
If still doesn't work, try this:
Code:

sudo ~/ims_bench/ims_bench_0$ ./prepare.sh
Note: Will ask for the root password, type it

Good luck with the scripts.

ShadowCat8 12-14-2010 01:18 PM

Greetings,

Can you give us the output of "ls -l /usr/local/" and then the output of "ls -l /usr/local/sipp/", if it exists, from one of the virtual systems?

Also, I am assuming that you are running these as root (on all boxes), correct? If not, then that could be the issue right there.

From my current system:
Code:

~ # ls -al /usr/local/
drwxr-xr-x 10 root    root    4096 Feb 26  2009 .
drwxr-xr-x 17 root    root    4096 Nov  2 13:57 ..
drwxr-xr-x 2 root    root    4096 Jun 17  2008 bin
drwxr-xr-x 2 root    root    4096 Jun 17  2008 games
lrwxrwxrwx 1 root    root      5 Jan 16  2009 lib -> lib64
drwxr-xr-x 2 root    root    4096 Jun 17  2008 lib32
drwxr-xr-x 2 root    root    4096 Jun 17  2008 lib64
lrwxrwxrwx 1 root    root      9 Jan 16  2009 man -> share/man
drwxr-xr-x 6 portage portage 4096 Dec 14  2009 portage
drwxr-xr-x 2 root    root    4096 Jun 17  2008 sbin
drwxr-xr-x 4 root    root    4096 Jun 17  2008 share
drwxr-xr-x 2 root    root    4096 Jun 17  2008 src

Only root can make a directory there, so if you are not running as root, you probably aren't making that directory on /usr/local/.

HTH. Let us know.

hiteurecomupf 12-15-2010 05:21 AM

Hello all,

As i said , i can ssh into both the virtual IP's (B&C) from the host A but only as a user not as a root. For example , i can do like this ,

sougata@sougata-desktop:~ ssh <ip B> -l sougata and it gets logged instantly but the moment i try to do like below -

sougata@sougata-desktop:~ ssh <ip B> -l root , it ask's for a password.
root@ip B:<> , and no matter how many times i give the root password for the machine A, as both the IP's B and C are virtual IP's on this host A , it doesn't take it. And after 3 times it get's out like this way below -

sougata@sougata-desktop:~ ssh <ip B> -l root
root@ip B's password:
Permission Denied
root@ip B's password:
Permission denied (publickey,password)

I can't even run the ./prepare.sh script as root as everytime i get this password asking.
So when i am running from user sougata like below , i am getting permission denied error like below ,

sougata@sougata-desktop:~/ims_bench/ims_bench_0$ ./prepare.sh
Preparing TS1 (ip B) ...
scp: /usr/local/sipp/ims_users_1.inf: Permission denied
scp: /usr/local/sipp/run_1.sh: Permission denied
scp: /usr/local/sipp/sipp: Permission denied
Error: Failed to prepare TS1

And when i am trying to run from root ,
root@sougata-desktop:~/ims_bench/ims_bench_0$ ./prepare.sh
Preparing TS1 (ip B) ...
root@ip B's password:
And that permission deny error and am getting out after 3 times.

Now what i am understanding from this error analysis(CORRECT ME IF I AM WRONG) is that, only if i can ssh to both the virtual IP's B and C from host A as ROOT , only in that scenario i can run the .prepare.sh script along with necessary permissions.

Now how to do this as i can only ssh as user but not as root. Trying so many times but failing everytime :((.

Btw , when i do ls -l , i see -

sougata@sougata-desktop:~/ims_bench$ ls -l
total 3776
-rw-r--r-- 1 root root 24430 2010-10-11 17:43 actions.cpp
-rw-r--r-- 1 root root 8743 2010-10-11 17:43 actions.hpp
-rw-r--r-- 1 root root 78232 2010-11-12 18:59 actions.o
-rw-r--r-- 1 root root 4930 2010-10-11 17:43 asyncevent.cpp
-rw-r--r-- 1 root root 2222 2010-10-11 17:43 asyncevent.hpp
-rw-r--r-- 1 root root 9188 2010-11-12 18:59 asyncevent.o
-rw-r--r-- 1 root root 18220 2010-10-11 17:43 auth.cpp
-rw-r--r-- 1 root root 12408 2010-11-12 18:59 auth.o
-rw-r--r-- 1 root root 139550 2010-11-12 18:37 call.cpp
-rw-r--r-- 1 root root 139522 2010-10-11 17:43 call.cpp~
-rw-r--r-- 1 root root 14764 2010-10-11 17:43 call.hpp
-rw-r--r-- 1 root root 195176 2010-11-12 18:59 call.o
-rw-r--r-- 1 root root 1619 2010-10-11 17:43 comp.cpp
-rw-r--r-- 1 root root 1706 2010-10-11 17:43 comp.h
-rw-r--r-- 1 root root 1808 2010-11-12 18:59 comp.o
-rw-r--r-- 1 root root 151 2010-10-11 17:43 convunix.sh
-rw-r--r-- 1 root root 13237 2010-10-11 17:43 cpumem.cpp
-rw-r--r-- 1 root root 14255 2010-10-11 17:43 csocket.cpp
-rw-r--r-- 1 root root 3787 2010-10-11 17:43 csocket.hpp
-rw-r--r-- 1 root root 26092 2010-11-12 18:59 csocket.o
-rw-r--r-- 1 root root 3511 2010-11-12 18:47 except.cpp
-rw-r--r-- 1 root root 3511 2010-11-12 18:46 except.cpp~
-rw-r--r-- 1 root root 6273 2010-10-11 17:43 except.hpp
-rw-r--r-- 1 root root 15900 2010-11-12 18:59 except.o
drwxrwxrwx 2 root root 4096 2010-12-14 17:14 ims_bench_0
-rw-r--r-- 1 root root 16959 2010-10-11 17:43 LICENSE.txt
-rw-r--r-- 1 root root 149 2010-10-11 17:43 local.mk
-rw-r--r-- 1 root root 9177 2010-10-11 17:43 Makefile
-rwxr-xr-x 1 root root 133992 2010-11-12 19:00 mana

Regards to all ,

Sougata

hiteurecomupf 12-15-2010 08:27 AM

Hi Shadowcat ,

I did ls -l /usr/local is showing me :

root@sougata-desktop:/home/sougata# ssh <ip B> -l sougata
sougata@<ip B's> password:
Linux sougata-desktop 2.6.31-22-generic #68-Ubuntu SMP Tue Oct 26 16:38:35 UTC 2010 i686

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/

Last login: Wed Dec 15 13:07:45 2010 from andreas-bmat.ca.upf.edu
sougata@sougata-desktop:~$
sougata@sougata-desktop:~$ ls -l /usr/local
total 40
drwxr-xr-x 2 root root 4096 2010-11-10 16:13 bin
drwxr-xr-x 2 root root 4096 2009-04-20 15:59 etc
drwxr-xr-x 2 root root 4096 2009-04-20 15:59 games
drwxr-xr-x 3 root root 4096 2010-11-10 15:45 include
drwxr-xr-x 7 root root 4096 2010-11-10 15:45 lib
drwxr-xr-x 3 root root 4096 2010-11-10 15:56 libexec
lrwxrwxrwx 1 root root 9 2010-10-11 16:40 man -> share/man
drwxr-xr-x 2 root root 4096 2009-04-20 15:59 sbin
drwxr-xr-x 17 root root 4096 2010-11-10 15:56 share
drwxr-xr-x 2 root root 4096 2010-12-13 17:10 sipp
drwxr-xr-x 2 root root 4096 2009-04-20 15:59 src

Kindly notice here , that i ssh into ip B using my username sougata but not using ROOT.
It's not letting me in using root, asking me password which i don't know what to give.
Here the password is the machine password of host A. But when i am going to do using root no password working. Just to mention also in my sshd_config file already permitted of getting connected through root.

Regards,

Sougata

hiteurecomupf 12-15-2010 10:52 AM

ahh finally solved... thanks to both of you for your helping inputs... :)
cheers ,
sougata

coexistance 12-15-2010 07:09 PM

Nice hiteurecomupf!
Can you please, post how you solved the problem if doesn't bother you, of course.

As that may will help in the case, I make a script dependent of other hosts.
If you can, thanks a ton, that would make me learn some stuff.
If not, well doesn't matter, what's important is that the problem is solved.

About the help, people are here for that, even if some members like me don't have master skills (far away from it, to be honest).
Cheers!

hiteurecomupf 12-16-2010 04:47 AM

HI coexistence ,

Actually my error was coming due to some stupid mistake which i was constantly making due to not having one clear fundamental idea on giving "user password" and "superuser password".

As i said, i was able to login as user sougata but not as root. But to run the script ./prepare.sh , i need to login as root. Now i didn't realise that in Ubuntu user password and root password can be different. As i was thinking both the passwords should be same (don't know from where did i get that stupid idea... lol). And moreover this error has been bothering me for the past 1 week. So finally i figured out reading the Ubuntu documentation on logging in as "su" and "su -". I had completely forgotton the su - password , which i need to input to run this script as a root. And continuously i was giving the user password as i was thinking if i can change login with command "sudo su" giving this password(user one) then why it was not working in this case. But here it needs the proper su - password.. damn stupid me...

Sometimes this kind of errors are so time consuming to solve yet the solution is so simple. So i guess my biggest learning experience is to hold patience and to see more minutely..lol

Cheers ,

Sougata

coexistance 12-16-2010 07:14 AM

Thanks for replied hiteurecomupf
That happens, actually it did happen to me once too, When I switched from Debian for Ubuntu.
Your right, sometimes the simplest problems can be the greatest headaches.
But we learn with the mistakes so I think overall the time consumption is well invested.

cheers and good "bashing"!


All times are GMT -5. The time now is 07:55 PM.