1

I want to copy a file from my Ubuntu Desktop(user:vverma) to a server named fb3, please guide me regarding how to scp this?

In order to reach fb3, i have to follow these steps:-

  1. ssh to server1 as user1 from my terminal
  2. ssh from server1 to server2 as user1
  3. sudo su - user2
  4. ssh from server2 to server3(which is fb3) as user2

Now please guide me that how can i accomplish this complicated tsak without creating any errors.

muru
  • 207,228
Vipin Verma
  • 5,524
  • 15
  • 45
  • 64

6 Answers6

4

I have always did it like this:

rcp filaname usernameinserver@server:path/in/server

The command will ask you for your password on the server (unless you are using another authentication schema).

Note that your user name in the local computer is not relevant.

rcp/scp are tunneled under ssh, it's probably the most secure way to copy a file. If you want increased security you can try to use key pars instead of passwords. It's more complicated to setup but after it's done you don't need to type your password for each transfer.

Javier Rivera
  • 35,434
4

there is absolutely no reason to be paranoid about ssh/scp, why should you be? It's safe.

scp myfile user@ip_or_server_name:path/to/myfile

path can be either relative or absolute

I assume that you have already generated your keys (ssh-keygen) and copied to your server (ssh-copy-id).

2

You can try rsync.

rsync -v -e ssh ~/Desktop/filename username@server:/path-in-server

Take a look at this page

Anwar
  • 77,855
1

You can make a shared folder in the server then connect to the server and copy to the shared folder then you can remove sharing from the folder

0

I know this question is kind of old. But maybe this can help somebody, the simplest way I would do this is to run the command below:

scp -r $HOME/work/projects/my-server root@121.32.200.55:"/var/www/example.com/public_html"

where:

  • /work/projects/my-server is your file location in your local machine.
  • root is the user name of your remote server
  • 121.32.200.55 is the IP address of the remote server
  • /var/www/example.com/public_html is the remote directory you are going to be copying the folder to

Normally you will be asked for the password to the server. Once provided the folder starts copying.

Marcel
  • 101
0

I understand this might be an old question, but I find it worthy to share my little experience to add some value. Run the command below, making changes as needed:

rcp -i private-key filaname username@server_ip_address:path/to/filename_in_server

This applies when you use the SSH keys as your authentication.

Explanation:

  • rcp: The command to copy files between servers.

  • -i: The attribute of the rcp command that invokes login using SSH keys.

  • filename: Your respective filename intended to be shared to the respe ctive server location.

  • username: Your recipient server's username used to log into the receiving server.

  • server_ip_address: The specific unique server IP address of the recipient.

  • :path/to/filename_in_server: The desired location of the file in the new location.

This method is efficient to those using an SSH authorised login server.