How to Set Up SSH Passwordless Connection
Connecting to remote servers quickly and securely is important for many tasks. Setting up SSH passwordless connections can help you do this without entering a password each time. It would be helpful to automate tasks such as cloning and more.
SSH Passwordless Connection Objective:
- Create SSH key pairs.
- Copy your public key to the remote server.
- Connect to your remote server without a password.
What is ssh:
SSH stands for Secure Shell, allowing connection to another machine over a network. It provides a secure way to remotely access and control another machine. It ensures the safety of your data, preventing anyone from seeing what is happening.
Benefits:
- Security
- Convenience
- Automation
Prerequisites:
- ssh install in both systems (local and remote machine)
- Access both servers
- Basic knowledge of Linux command
SSH Passwordless Connection Action Plan:
Step 1:
Open the terminal and connect to the user ex: “Oracle” in your local machine.
Step 2:
Now we need to create a pair of SSH keys on your local machine
ssh-keygen
Enter the file in which to save the key (/home/oracle/.ssh/id_rsa):
leave the default location (empty) you can press Enter to skip it
Enter passphrase (empty for no passphrase):
Do you want to enter the passphrase you can enter in my case I am leaving the default (empty) you can press Enter to skip it.
Step 3:
Verify the Public key and private key.
ls -ltr .ssh/
Notice this name ‘id_rsa.pub’ this is the public key.
Step 4:
Copy the Public key to a remote server Enter your username and remote server IP
ssh-copy-id username@<remote_host_ip>
Step 5:
Verify the public key in the Remote server in the ‘.ssh’ directory, Change your path
cat /home/oracle/.ssh/authorized_keys
Step 6:
verify the password-less connection, change your username and IP address
ssh username@<remote_host_ip>
Now, we have successfully connected to the remote server from the local server using SSH without needing a password.
Thank you