77.2k views
0 votes
How to pass password in ssh command

User Mageworx
by
7.5k points

1 Answer

6 votes

Final answer:

Passing a password in an SSH command is insecure. It is better to use an SSH key pair for authentication. For automation, tools like sshpass can be used, though they bring security risks.

Step-by-step explanation:

To pass a password in the ssh command, you can use the SSH key-based authentication method instead of providing the password directly. Here are the steps to set it up:

Generate an SSH key pair on your local machine using the ssh-keygen command.

Copy the public key to the remote server's ~/.ssh/authorized_keys file.

Set appropriate permissions on the server's ~/.ssh/authorized_keys file.

Now, when you connect to the remote server using the ssh command, it will authenticate you with the SSH key pair instead of asking for a password.

User IAmoric
by
7.8k points