1755131 Members
2752 Online
108830 Solutions
New Discussion

scp automated script

 
Fenglin
Regular Advisor

scp automated script

Hi

I am able to manually scp some files from HP-UX server to a linux server.

If I want to automate that process since those files will be generated on a daily basis, I would like to know what is the best way to write.

Currently, the manual way is as follows :

scp filenames idname@hostname:/home/idname

after key in the password, the files are transferred over.

Thanks a lot.
Feng Lin

1 REPLY 1
Suraj K Sankari
Honored Contributor

Re: scp automated script

Hi,
Here is the step how to configure ssh without passwd

Using the below steps, you can ssh to the server from client without the entering any password.
The machine which run the ssh command is the client
The machine that the client access using ssh is the server



Run the following command on the client
-> ssh-keygen -t dsa

File id_dsa and id_dsa.pub will be created inside $HOME/.ssh
Copy id_dsa.pub to the server's .ssh directory
-> scp $HOME/.ssh/id_dsa.pub user@server:/home/user/.ssh
Change to /root/.ssh and create file authorized_keys containing id_dsa content
-> cd /home/user/.ssh
-> cat id_dsa >> authorized_keys
You can try ssh to the server from the client and no password will be needed

-> ssh user@server
Another alternative to the above steps is to use ssh-copy-id command. The steps are:

Run the following command on the client
-> ssh-keygen -t dsa
File id_dsa and id_dsa.pub will be created inside $HOME/.ssh
Copy the id_dsa.pub to the server's .ssh directory
-> ssh-copy-id -i ~/.ssh/id_dsa.pub user@server
You can try ssh to the server from the client and no password will be needed

-> ssh user@server

Once your ssh without passwd is configured then you can run your scp script it will work

Suraj