Linux SCP issue
-
@johnhooks said:
As far as I know (I could be wrong) to scp to / you need to be root or sudo the scp
Nope, nothing like that. SCP is just a protocol on SSH. If you can log in, you can SCP.
-
@johnhooks said:
It's also not a good idea to have the password in the script. It should be kept in a file with 400 permissions for the user, or ideally use a key.
It should only ever be a key.
-
@scottalanmiller said:
@johnhooks said:
As far as I know (I could be wrong) to scp to / you need to be root or sudo the scp
Nope, nothing like that. SCP is just a protocol on SSH. If you can log in, you can SCP.
Don't you need to have sudo permissions or be root to copy to the root folder though?
-
@johnhooks said:
Don't you need to have sudo permissions or be root to copy to the root folder though?
Ah, not necessarily. But 99% of the time, yes.
-
for i in
find /home/msftp/cdr -type f -ctime -1
Backticks are a bad practice from like a decade ago. It should be written this way:
for i in $(find /home/msftp/cdr -type f -ctime -1)
-
Run this command manually, does it fail?
scp $i [email protected]:/
-
What error are you getting? You asked us if there was a problem but did not state what issue you were having.
-
@scottalanmiller The remote server is administered by a different company. I was told just a few minutes ago that they haven't asked... Told them to use rsync but haven't heard back yet.
-
What is the output of this command?
find /home/msftp/cdr -type f -ctime -1
-
@BBigford said:
@scottalanmiller The remote server is administered by a different company. I was told just a few minutes ago that they haven't asked...
Should not need to ask. If you have the right to log in as that user, you set up the key yourself. The other company likely has no control there. That would be unlikely.
-
@BBigford said:
@scottalanmiller The remote server is administered by a different company.
So the chances that you have access to write to / are nearly zero, then. That's probably your issue.
-
@scottalanmiller the admin says that the script will run, but simply doesn't copy. There's no error thrown (sorry that isn't more helpful). If he would get back to me already, I'd have him run those commands right now.
-
@BBigford said:
Told them to use rsync but haven't heard back yet.
Rsync is a good tool to use, of course, but unlikely to matter here.
-
Got it figured out. Turns out that the directory being called, didn't exist. All good now though, thanks for all the quick responses!
-
@BBigford said:
Got it figured out. Turns out that the directory being called, didn't exist. All good now though, thanks for all the quick responses!
It did exist, it's the filesystem root. The issue was that the user did not have permissions there I'm sure this was caused by accidentally forgetting the correct directory when making the script, but there is a director specified, it's just not one you would want to use
-
Had to finish some stuff at work and eat dinner with the wife and kiddo, but I was thinking about it. Once they set up a key you can do this with one line (if you don't use a key you would need the password for each file).
find /home/msftp/cdr -type f -ctime -1 -exec scp {} [email protected]:/whatever/folder \;
-
Yeah, you can get that to be pretty simple with a little work (and keys.)