How To Use SSH With Password On Command Line

How To Use SSH With Password On Command Line

To use SSH with a password on the command line, you can use the ssh command followed by the username and the hostname or IP address of the remote system.

For example:

ssh username@remote_host
Source:w‮ual.ww‬tturi.com

This command will connect to the remote system remote_host as the user username, and prompt you for the password for the user.

If the remote system requires a different port than the default SSH port (22), you can specify the port number with the -p option. For example:

ssh -p 2222 username@remote_host

This command will connect to the remote system remote_host on port 2222 as the user username, and prompt you for the password for the user.

You can also use the sshpass utility to specify the password on the command line. sshpass is a utility that allows you to specify the password for ssh on the command line, without having to enter it manually.

To use sshpass, you will need to install it first. On most Linux distributions, you can install sshpass by running the following command:

sudo apt-get install sshpass

Once sshpass is installed, you can use it to specify the password for ssh on the command line. For example:

sshpass -p 'password' ssh username@remote_host

This command will connect to the remote system remote_host as the user username, and use the password password to authenticate the connection.

Keep in mind that using sshpass to specify the password on the command line is not secure, as the password is visible to anyone who has access to the command line or the command history. It is generally recommended to use key-based authentication with ssh instead of passwords, if possible.

For more information about how to use ssh and sshpass, you can consult the ssh and sshpass man pages by running the man ssh and man sshpass commands, respectively.

Created Time:2017-10-29 22:08:34  Author:lautturi