How to use
ssh command in a same script? First I have to copy one file from my local server to remote. Then from local server itself, I have to check the size of the copied file.
I would use public/private key to automate the conection without the need of using a password.
Yes, you need keys. Step 1. generate them At terminal (assuming CentOs/RHEL or similar): ssh-keygen (quick-shortcut - YES - to all)
Step 2. Put your public keys onto that remote server. Actually save yourself trouble and run the following: ssh-copy-id @
Done. You have your keys on the remote system now. Now you can test logging in without the password (password-free-access)
Test with: ssh @ If you get to login without any prompt for password. super.
Then you can just copy things over and do all those file size checks now : scp file.ext @:/some/location ; ssh @ "du /some/location/file.ext"