1827395 Members
5446 Online
109965 Solutions
New Discussion

Re: correct scp syntax

 
Ragni Singh
Super Advisor

correct scp syntax

I am currently on my system. I need to scp from another system as a different user a file to my system as such and am having issue.

What am I doing wrong here.

snort>scp user@xxx.xx.xx.x:test xxx.xx.xx.xx:/home/user.

I know if I am on snort now and I want to scp something to another host, I do the following..

snort> scp test 172.24.10.0:/home/user.

What about if I want to scp from another host as a different user?

Thanks and points will be assigned.
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: correct scp syntax

Shalom Sanjit,

I'm on snort. The server, not the drug.

I am logged in as user schmo.

I want to log into or scp (the syntax is the same) server bagel as user user2

snort>scp /usr/local/files/* user2@bagel:/targetdir

There is no way I know around a password prompt here but this command will copy files from snort to bagel and log in as user user2. It is up to you as the administrator to make sure user schmo on server snort has rights to write files to the target directory on server bagel.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: correct scp syntax

Shalom Sanjit,

I'm on snort. The server, not the drug.

I am logged in as user schmo.

I want to log into or scp (the syntax is the same) server bagel as user user2

snort>scp /usr/local/files/* user2@bagel:/targetdir

There is no way I know around a password prompt here but this command will copy files from snort to bagel and log in as user user2. It is up to you as the administrator to make sure user schmo on server snort has rights to write files to the target directory on server bagel.

The hostnames bagel can be replaced with a numeric ip address. You don't need to specify the ip address of the local system.

I've never tried to use scp to go from two remote servers. Sounds like an interesting experiment though.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ivan Ferreira
Honored Contributor

Re: correct scp syntax

The general syntax is:

localfile from server1 to server2

server1> scp /path/to/localfile user@server2:/path/to/destination

remotefile from server2 to server1
server1> scp user@server2:/path/to/remotefile /path/to/localdir
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Muthukumar_5
Honored Contributor

Re: correct scp syntax

You have to give user and hostname or ip-address information to remote machine only.

Copying remote file to local machine:

scp remote-user@:/location /local location

scp root@172.19.0.1:/tmp/* /tmp/test/

Copying local file to remote machine:

scp /tmp/test/* root@172.19.0.1

No need to use user with hostname or ip-address to localmachine since it is known.

--
Muthu
Easy to suggest when don't know about the problem!
Indrajit_1
Valued Contributor

Re: correct scp syntax

Hi;

Try this

#scp file_name user_name@host.domain.com:/export/home(path)


cheers
indrajit
Never Ever Give Up