koolnhot
04-16-2009, 07:09 AM
I am a beginner with ssh, so need some help
I would like to know the code for ssh to transfer files from an ip to another ip address.
for eg:
like to transfer data from 1.1.1.1 to 2.2.2.2 how to do it ?
Codebird
04-16-2009, 07:34 AM
from the server to server:
scp yourusername@1.1.1.1:/path/to/the/file yourusername2@2.2.2.2:/path/to/where/u/want/the/file
from your pc to a server:
scp filename yourusername@2.2.2.2:/path/to/where/u/want/the/file
koolnhot
04-16-2009, 07:51 AM
the username refers to the ssh user name rite ?
Its between 2 vps, not from pc
Codebird
04-16-2009, 07:59 AM
scp yourusername@1.1.1.1:/path/to/the/file
this username should be a username that have at least read permission on the file to copy
yourusername2@2.2.2.2:/path/to/where/u/want/the/file
this should have write permission on the directory where u're putting the file
koolnhot
04-16-2009, 08:23 AM
so can we use the "root" ssh account, as it would have complete privileges ?
so I can use like this rite
scp root@1.1.1.1:/home/admin/doc/fp/rc.zip root@2.2.2.2:/home/admin/doc/fp/
here rc.zip is the file to b moved
???
Codebird
04-16-2009, 08:27 AM
yep that's right rc.zip is the file to be copied not moved
rankris
04-16-2009, 08:39 AM
rsync also will do the job if you need to transfer the entire directory.
rsync -avz source/directory/location destination_IP:/location/where/the directory/should/be placed
koolnhot
04-17-2009, 08:43 AM
rsync is a bit risky for me, if any file fails to transfer, I am zipping the dir and copying it to new host, so I guess scp would help me good ;)
thanks for the help codebird and rankris
I would like to know 1 more doubt,
when passed the scp command, will it ask for pwd for the useraccount ??
If yes, which account will it first as both usernames are same it can be confusing for beginners in ssh like me
Codebird
04-17-2009, 08:48 AM
for sure it will ask for both accounts' passwords, never tried it from server to server though, but I am pretty sure it won't be confusing... if it is confusing, all u have to do is try a password then the other u'll know
as for copying directories u can just use
scp -r user@ip:/path/to/the/directory user@ip:/path/to/where/u want/to/store/it
-r for recursive copy
gigatux
04-20-2009, 05:12 AM
so can we use the "root" ssh account, as it would have complete privileges ?
so I can use like this rite
scp root@1.1.1.1:/home/admin/doc/fp/rc.zip root@2.2.2.2:/home/admin/doc/fp/
here rc.zip is the file to b moved
???
Take care with the root account. Most SSH services (that scp really uses) do not allow logins using root. Your sshd configuration file (often /etc/ssh/sshd_config) should have a PermitRootLogin directive. If this is 'no', you won't be able to transfer files from/to a remote root account.