-1

is there a way to transfer file.txt from one of my server to another via ssh?

i have ip addresses, root usernames and passes both server's. I've read this topic ==> How to upload local file to server through Linux terminal

but i couldn't understand what hostname means? I have only ip addresses and passwords of root username. And want to transfer file.txt from server 1 to server 2 (from main folder to main folder)

Benjamin
  • 101

1 Answers1

1

You can use SCP. The syntax is scp local_file server2_user@server_2_ip_address:/path_to_destiny_folder.

Example: cp /etc/rsyslog.conf root@192.65.4.64:/etc/rsyslog.con # copy the rsyslog settings from one server to another.

To automate it via a script you need to generate a ssh keys pair. It will allowed a user login from a server to another without a password. In your case, log as root in server1 and type:

ssh-keygen -t rsa -b 4096

Type enter for all options

cat ~/.ssh/id_rsa.pub

Copy the output command.

login as root in server2 and paste the previous result to the ~/.ssh/authorized_keys file (with it doesn't exist, so create it yourself)

See the full procure at: https://stackoverflow.com/questions/4388385/how-to-ssh-login-without-password