Written a script to ssh to any machine (with a fixed username and password), without worrying about changes to public ssh keys
Script Steps
- Check if any argument is given to the script, if not then exit
- Find any public SSH key for the given IP in known_hosts and delete them
- Add the latest public SSH key of the given IP to /.ssh/known_hosts
- Try to ssh
How to run
-
Clone the repo
-
Add Username and Password in klogin file
-
Install sshpass using your package manager, brew for MacOS users, use yum package manager for CentOS/RHEL
brew install sshpass
-
Make the klogin file as an executable
chmod +x klogin
-
Add the path of this directory to your PATH, example: "/Users/garvit.bhateja/sshpass-script"
sudo vi /etc/paths
-
SSH using follwoing command
klogin 10.10.10.10