I am new to Shell scripting. I want to login to a server using a script. The normal command I use is --> sudo ssh <Servername> . when i tried putting this into a txt format file and tried running, it throw an error "can't execute". I am an Admin and i have root access. Any help would be highly appreciated.
I am trying to setup keys between 2 unix servers automatically. Thats what i am trying to do. Script should get source and destination server from me and shoudld login automatically.
---------- Post updated at 11:58 PM ---------- Previous update was at 11:51 PM ----------
I am using this command inside the script,just to verify if it works.
You don't need root for this, though. You can just do ssh root@host without needing to run ssh as root.
But permitting root login for ssh is dicey. People will be trying to crack the password on that, best not to let them even try. What I generally do is:
ssh username@host sudo ...
where 'username' is set up to allow login with a key and sudo configured to allow that username.