Operating System - HP-UX
1832898 Members
2362 Online
110048 Solutions
New Discussion

Re: scp from local to other hosts

 
Prashant Zanwar_4
Respected Contributor

scp from local to other hosts

Hi,
I have got a Linux host. I am having some file which I need to remote host to destination location.
scp $file pzanwar@host:/etc/mail/aliases

says permission denied.
What I tried doing is sent the file to my home directory and then ssh sudo cp -p ~pzanwar/ /etc/mail/aliases

This says destination shud be directory..

I want to know y scp is failing first. and how do i acheive this. same happens with mv also.
password gets through..though
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
6 REPLIES 6
Sanjay_6
Honored Contributor

Re: scp from local to other hosts

Hi,

try this as,

scp $file root@host:/etc/mail/aliases

hope this helps.

Regds
Prashant Zanwar_4
Respected Contributor

Re: scp from local to other hosts

I have sudo setup in my environment, I have sudo access to all hosts. Problem is how to use that with scp, or how do i get myself authenticated as root if I use scp?
Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Ralph Grothe
Honored Contributor

Re: scp from local to other hosts

I'm not sure how sudo integrates in SSH as far as authentication and authorization are concerned.
I suppose both can use the pluggable authentication modules (PAM).
But this is a matter of how the tools were compiled and how they are configured.
At least from the OpenSSH sshd_config I know that there exists a directive UsePAM, and that the by HP distributed "Secure Shell" for HP-UX (which is a build from OpenSSH) has PAM support enabled and comes with sshd.pam.* libs.

Is your root access on the remote host fully restricted by sudo, or do you have a chance to place files in root's home dir?
If the latter is true you can either create a ~root/.shosts file (not the preferred method), or create a key pair of your local account and append it to ~root/.ssh/authorized_keys on remote host.
But you have to know how the remote sshd is configured, i.e. be able to look at its sshd_config to see what is allowed.
There are too many directives that rule the behaviour of the remote sshd for me to spell them all out here.
If you were able (and willing, caveat security policy) to post the contents of the sshd_config of remote host here we could advise you what would work, and probably what would be advisable as Dos and Don'ts.
Madness, thy name is system administration
Prashant Zanwar_4
Respected Contributor

Re: scp from local to other hosts

I cannot disclose any security policy for obvious reasons...

Suggestion is good though. Thanks a lot.
I will probably take help of security guys to make this work.

Thanks a lot.
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
RAC_1
Honored Contributor

Re: scp from local to other hosts

Your following syntax is wrong.

ssh sudo cp -p ~pzanwar/ /etc/mail/aliases

You need to as follows. (As a pzanwar user)

sudo scp $file root@host:/etc/mail/aliases
I assume that you have set root user for authentication.

Anil
There is no substitute to HARDWORK
Michael Selvesteen_2
Trusted Contributor

Re: scp from local to other hosts

Hello,

Try the following,

cat $file | ssh RemoteMachine 'cat >> /etc/mail/aliases'

Permisson Denied problem may arise,due to

1. Your account may expired in remote machine.
2. You may not have nescessary privileges
to create a file in remote machine.

Try the following,

1. Run scp in debug mode as follows
scp -v $file username@remotehost:/dest/dir

It can figure out possible causes of problems.

2. If possible run the server in debug mode to find the fault.

Hope this helps.

--
M