I am executing the following in my script:
Which asks me for a password
How do I execute the script to create the ssh connection and then pass the password into it, so I don't have to type it?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
What your looking for is
ssh keys, then you wont have to type a
To generate RSA keys, on the command line, enter:
ssh-keygen -o -b 4096 -t rsa
NOTE THIS: If you don't password-protect your private key, anyone with access to your computer conceivably can SSH (without being prompted for a password) to your account on any remote system that has the corresponding public key.
Your private key will be generated using the default filename (for example,
id_rsa) or the filename you specified (for example, my_ssh_key), and stored on your computer in a .ssh directory off your home directory (for example,
If your account on the remote system doesn't already contain a
~/.ssh/authorized_keys file, create one; on the command line, enter the following commands:
mkdir -p ~/.ssh touch ~/.ssh/authorized_keys
To copy your key to the remote server:
ssh-copy-id is a utility available on some operating systems that can copy a
SSH public key to a remote server over
ssh-copy-id, pass your username and the IP address of the server you would like to access:
There are several ways to do this, but I recommend using public/private keys rather than passing the password (which is possible). There are many other answers on this - but here is a quick how to:
On the machine you are logging in from:
Create a public/private key combination:
ssh-keygen -t rsa
Copy the public key to the remote machine:
You will then need to type your password, and the public key will be copied to 192.168.1.89. At this point you will no longer be asked for your password upon logging in from the first machine.