Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    35
    Rep Power
    5

    Unable to copy file using SCP (Input/output & Permission denied error)


    Hi,


    I am facing issue while using scp. Source & target machines are Linux & HP-UX respectively.

    On target machine, if I fire the following command, I get error:

    Code:
    bash-2.05# scp jim@source:/builds/20110622/trunk/hpux/abc.jar .
    jim@source's password:
    abc.jar 100% 33MB 8.2MB/s 10.2MB/s 00:04
    scp: /builds/20110622/trunk/hpux/abc.jar: Input/output error
    Now if I try scp on another file, which is on the same source machine, it works fine.

    Code:
    bash-2.05# scp jim@source:/builds/20110622/trunk/linux/xyz.jar .
    jim@source's password:
    xyz.jar 100% 15MB 7.5MB/s 8.4MB/s 00:02
    bash-2.05#
    All directories and subdirectories for both the source files have same permissions. Even the source files themselves have identical permissions set. The target location is also the same. Still, I am getting error for one file, and not for the other.

    One thing to be noted is that the error description changes after I get the above input/output error. On second (and further attempts) unsuccessful try, I get the following error message:

    Code:
    bash-2.05# scp jim@source:/builds/20110622/trunk/hpux/abc.jar .
    jim@source's password:
    abc.jar 100% 33MB 8.2MB/s 10.2MB/s 00:04
    scp: /builds/20110622/trunk/hpux/abc.jar: Permission denied
    Another thing to be noted is that this copy operation was working fine few days back. Suddenly, the user has started getting this error. I understand that something might have changed but I am really finding it hard to figure that out.

    Also, both the source files get copied successfully when I use scp with some other userís credential.

    Any help would really be appreciated.


    Thanks,
    Gaurav
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,446
    Rep Power
    1751
    Check the ownership and permissions of the file on the target server
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    35
    Rep Power
    5
    Originally Posted by SimonJM
    Check the ownership and permissions of the file on the target server
    Thanks for your reply.

    The ownership of the file changes to that of the user (jim) who is doing the scp. File permissions remain the same as they are on the source server.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,446
    Rep Power
    1751
    At a bit of a loss ...
    The permissions on the source server (the one you are pulling the file from) must be adequate to the need as you do seem to be transferring data. Likewise the file on the target server (the one you are doing the pull from).
    It looks like the file is copied, and then there is an error. The stuff that happens at the end are: setting ownership and permissions - basically updating the stuff you find in inodes.
    Directory permissions should be ok as you can pull in other files.
    Does anything different happen if you delete the file (if it exists already) on the target server?
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    35
    Rep Power
    5
    The file on the source (where i am pulling from) has the following attribute:

    -r-xr-xr-x 1 harry bin 52637233 Jun 6 12:47 abc.jar

    When i use scp using the following command on the target/destination server (where i want it finally),

    scp jim@source:/builds/20110622/trunk/hpux/abc.jar .


    i get following error message:

    scp: /builds/20110622/trunk/hpux/abc.jar: Input/output error


    and the attribute of the given file on the target/destination server (where i want it finally) becomes

    -r-xr-xr-x 1 jim other 52637233 Jun 29 16:43 abc.jar


    When i try to delete the file on the remote/destination server, it just prompts once because of permission

    bash-2.05$ rm abc.jar
    esm.tpk: 555 mode ? (y/n) y
    bash-2.05$

    Regarding the point that the file might have got copied and then the error occurs, I tried using scp with verbose option. Here is the output:
    -------------------------------------------------------
    bash-2.05$ scp -v jim@source:/builds/20110622/trunk/hpux/abc.jar .
    Executing: program /opt/ssh/bin/ssh host source, user jim, command scp -v -f /builds/20110622/trunk/hpux/abc.jar
    OpenSSH_4.3p2-hpn, OpenSSL 0.9.7i 14 Oct 2005
    HP-UX Secure Shell-A.04.30.007, HP-UX Secure Shell version
    debug1: Reading configuration data /opt/ssh/etc/ssh_config
    debug1: Connecting to source [source] port 22.
    debug1: Connection established.
    debug1: identity file /unixhome/jim/.ssh/id_rsa type -1
    debug1: identity file /unixhome/jim/.ssh/id_dsa type -1
    debug1: Remote protocol version 1.99, remote software version OpenSSH_3.1p1
    debug1: match: OpenSSH_3.1p1 pat OpenSSH_2.*,OpenSSH_3.0*,OpenSSH_3.1*
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_4.3p2-hpn
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client aes128-cbc hmac-md5 none
    debug1: kex: client->server aes128-cbc hmac-md5 none
    debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
    debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
    debug1: Host 'source' is known and matches the RSA host key.
    debug1: Found key in /unixhome/jim/.ssh/known_hosts:1
    debug1: ssh_rsa_verify: signature correct
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey,password,keyboard-interactive
    debug1: Next authentication method: publickey
    debug1: Trying private key: /unixhome/jim/.ssh/id_rsa
    debug1: Trying private key: /unixhome/jim/.ssh/id_dsa
    debug1: Next authentication method: keyboard-interactive
    debug1: Authentications that can continue: publickey,password,keyboard-interactive
    debug1: Next authentication method: password
    jim@source's password:
    debug1: Authentication succeeded (password).
    debug1: channel 0: new [client-session]
    debug1: Entering interactive session.
    debug1: Sending command: scp -v -f /builds/20110622/trunk/hpux/abc.jar
    Sending file modes: C0555 52637233 abc.jar
    Sink: C0555 52637233 abc.jar
    abc.jar 100% 50MB 10.0MB/s 00:05
    scp: /builds/20110622/trunk/hpux/abc.jar: Permission denied
    debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    debug1: channel 0: free: client-session, nchannels 1
    debug1: fd 0 clearing O_NONBLOCK
    debug1: fd 1 clearing O_NONBLOCK
    debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 4.7 seconds
    debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
    debug1: Exit status 1
    bash-2.05$

    -------------------------------------------------------

    From the above result, it looks like the file is getting transferred (not totally sure), and then instantly, we see the error message.


    Thanks,
    Gaurav
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,446
    Rep Power
    1751
    It's the permissions by the look of it:
    Sending file modes: C0555 52637233 abc.jar
    Sink: C0555 52637233 abc.jar
    abc.jar 100% 50MB 10.0MB/s 00:05
    scp: /builds/20110622/trunk/hpux/abc.jar: Permission denied
    Ending up, or starting off with r-xr-xr-x gives NO write permission.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    35
    Rep Power
    5
    I agree but then then why another file on the same source server with exactly same permission get copied using similar command in the same destination folder? The below file gets copied without any error. This is what is confusing me.

    bash-3.00$ scp jim@source::/builds/20110622/trunk/linux/xyz.jar .
    jim@source's password:
    xyz.jar 100% |********************************************************************************************| 27549 KB 00:02
    bash-3.00$
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,446
    Rep Power
    1751
    Compare:
    The ownerships and permissions of the directory containing the files on both source and target server.
    The ownerships and permissions of the actual files to be copied on both source and target server.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    35
    Rep Power
    5
    On source server:
    -------------------------------------------------------------------------------------
    sh-2.05$ pwd
    /builds/20110622/trunk
    sh-2.05$
    sh-2.05$ ls -ld linux/
    drwxrwxrwx 2 esm2 bin 512 Jun 6 12:45 linux/
    sh-2.05$ cd linux/
    sh-2.05$ ls -ltr xyz.jar
    -r-xr-xr-x 1 esm2 bin 28211037 Jun 6 12:45 xyz.jar
    sh-2.05$
    sh-2.05$ cd ..
    sh-2.05$ ls -ld hpux/
    drwxrwxrwx 2 esm2 bin 512 Jun 15 16:13 hpux/
    sh-2.05$ cd hpux
    sh-2.05$ ls -ltr abc.jar
    -r-xr-xr-x 1 esm2 bin 34169078 Jun 6 12:50 abc.jar
    -------------------------------------------------------------------------------------


    On destination server:
    -------------------------------------------------------------------------------------
    bash-2.05$ ls -ld /unixhome/jim
    drwxr-xr-x 18 jim other 1024 Jun 30 13:23 /unixhome/jim
    bash-2.05$
    bash-2.05$ cd /unixhome/jim/
    bash-2.05$
    bash-2.05$ scp jim@source:/builds/20110622/trunk/linux/xyz.jar .
    jim@source's password:
    xyz.jar 100% 15MB 7.5MB/s 8.4MB/s 00:02
    bash-2.05$
    bash-2.05$
    bash-2.05$ ls -ltr xyz.jar
    -r-xr-xr-x 1 jim other 28211037 Jun 30 13:27 xyz.jar
    bash-2.05$
    bash-2.05$ rm xyz.jar
    xyz.jar: 555 mode ? (y/n) y
    bash-2.05$
    bash-2.05# scp jim@source:/builds/20110622/trunk/hpux/abc.jar .
    jim@source's password:
    abc.jar 100% 33MB 8.2MB/s 10.2MB/s 00:04
    scp: /builds/20110622/trunk/hpux/abc.jar: Input/output error
    bash-2.05$
    bash-2.05$ ls -ltr abc.jar
    -r-xr-xr-x 1 jim other 34169078 Jun 30 13:30 abc.jar
    bash-2.05$
    bash-2.05$ id
    uid=117(jim) gid=1(other)
    -------------------------------------------------------------------------------------
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,446
    Rep Power
    1751
    Ok, what happens if you:

    a) scp the xyz file without having first deleted it
    b) scp the abc file but deleting it beforehand
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    35
    Rep Power
    5
    >>> a) scp the xyz file without having first deleted it

    bash-2.05$ scp jim@source:/builds/20110622/trunk/linux/xyz.jar .
    jim@source's password:
    xyz.jar 100% 15MB 7.5MB/s 8.4MB/s 00:02
    bash-2.05$
    bash-2.05$ scp jim@source:/builds/20110622/trunk/linux/xyz.jar .
    jim@source's password:
    ./xyz.jar: Permission denied
    bash-2.05$


    >>> b) scp the abc file but deleting it beforehand

    bash-2.05$ rm abc.jar
    abc.jar: 555 mode ? (y/n) y
    bash-2.05$
    bash-2.05# scp jim@source:/builds/20110622/trunk/hpux/abc.jar .
    jim@source's password:
    abc.jar 100% 33MB 10.9MB/s 00:03
    scp: /builds/20110622/trunk/hpux/abc.jar: Permission denied
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,446
    Rep Power
    1751
    Ok, I suspect the first one (with xyz.jar) can be explained by the local permissions denying over-write.
    The second one (with abc.jar) ... um ...???? That HAS to be linked to trying to update the inode on the local server somehow. Something must be different between the two files in some way as you are copying them both to the same local directory.

    When you did that last test did the file abc.jar actually get created on the local server?
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    35
    Rep Power
    5
    >>> Ok, I suspect the first one (with xyz.jar) can be explained by the local permissions denying over-write.

    Yes, you are right. That's expected behaviour.

    >>> The second one (with abc.jar) ... um ...???? That HAS to be linked to trying to update the inode on the local server somehow. Something must be different between the two files in some way as you are copying them both to the same local directory. When you did that last test did the file abc.jar actually get created on the local server?

    Yes the file gets created on the local server. Though it shows the exact size but it's corrupt. When i copy the other file (xyz.jar), it gets executed properly.

    From the verbose log that i posted earlier, can we say for sure that the transfer to the destination server happened successfully, and then the file got corrupted on that server?

    Is there any way to confirm your inode theory? If that is correct then shouldn't copying the other file also throw the same error message?


    Thanks,
    Gaurav
  26. #14
  27. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,945
    Rep Power
    4033
    Out of curiosity, what if you make a copy of abc.jar on the source server and then try and transfer the copy? Does it also fail, or does it succeed?

    Also, you can add more debug output by adding additional -v flags. Try -vvv
    Last edited by kicken; July 1st, 2011 at 02:36 AM.
    Recycle your old CD's, don't just trash them



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,446
    Rep Power
    1751
    To add to what kicken says, are you sure the source file is correct and valid?
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo