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.

3
  • I am basically stuck at step 3 where i have to switch from user1 to user2 on server2, i don't know about the priveleges of these two users on server2, so where to paste the file on server2, which one is the directory which will be common to both users on this server Sep 21, 2012 at 10:07
  • Why do you have to do step 3? You can always ssh / scp using username@server; you can always copy the authentication keys if necessary.
    – January
    Sep 21, 2012 at 10:46
  • This is called multi-hop SSH, and no you can't always copy authentication keys. Transparent multi-hop involves chaining SSH. Nowadays you would put ansible on the intermediate server to automate the sudoing, depending upon the age of the servers and how leveled their Python is.
    – mckenzm
    May 30, 2019 at 1:00

6 Answers 6

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.

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).

0
2

You can try rsync.

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

Take a look at this page

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 [email protected]:"/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.

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .