1752422 Members
5755 Online
108788 Solutions
New Discussion юеВ

Re: scp to remote host

 
SOLVED
Go to solution
hangyu
Regular Advisor

scp to remote host

I have two hosts - host A and host B

hostA can ssh to hostB via dedicated port 1022 , ( ssh -p 1022 hostB -l root ) , it works , only 1022 port is released.

now I want to cp the file from hostA to hostB ( the command is scp file -p 1022 hostB:/tmp -l root , but fail , can advise what is wrong ? thx


the error is
cp: missing destination file
Try `cp --help' for more information.
cp: cannot stat `1022': No such file or directory
root: Not a directory
8 REPLIES 8
Harmanjit_1
Frequent Advisor
Solution

Re: scp to remote host

Hi,

Can you pls. try with the either of the following syntax.

scp -P 1022 root@hostA:file root@hostB:/tmp/file

OR

scp -P 1022 file root@hostB:/tmp/file

Thanks
hangyu
Regular Advisor

Re: scp to remote host

thx reply ,

I tried two methods , but also not work , do I need to release or set sth at hostA side , please advise ? thx
Peter Nikitka
Honored Contributor

Re: scp to remote host

Hi,

your syntax is not correct, use

scp -P 1022 file root@hostB:/tmp/file

as Harmanjit stated. Note that you have to use a
capital letter 'P', not lower case '-p' for the port specification!
Using a lower case '-p' leads exactly to your error message.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Senthil Prabu.S_1
Trusted Contributor

Re: scp to remote host

Hi,
Use this;
scp -p 22 @hostB:/tmp

HTH,
Prabu.S
One man's "magic" is another man's engineering. "Supernatural" is a null word.
Peter Nikitka
Honored Contributor

Re: scp to remote host

Keep coll Hangyu,

Prabu is wrong:
Uppercase letter -P' is right!

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
derek b smith_1
Regular Advisor

Re: scp to remote host

yes -P is correct, but what I wanted to gather all /etc/passwd files from non-master servers on to one master host?

From master host:
#> scp -P 22 user@remotehost:/tmp/file masterhost:/tmp/newfilename
Heironimus
Honored Contributor

Re: scp to remote host

You shouldn't specify the name of the machine you're on. What you want is just:

scp -P 22 user@remotehost:/tmp/file /tmp/newfilename
Coolmar
Esteemed Contributor

Re: scp to remote host

scp -P port remotehost:/etc/passwd /dir/passwd.`hostname`