I want to connect to my ssh with this command :
ssh host@myhost ls -l /
but i want to enter my password in the above command , Is this Possible ? for example our command is like this :
ssh host@myhost mypassword ls -l /
|
I want to connect to my ssh with this command :
but i want to enter my password in the above command , Is this Possible ? for example our command is like this :
| ||||
|
feedback
|
This question came from our site for professional and enthusiast programmers.
|
To use SSH without passwords, you'll need to set-up keys to use on your system and the target system.
Then transfer the id_rsa.pub file to the target system. On your target system then add the public key to the list of authorised keys:
Log out. If you have left the passphrase on your key empty, you can now run the command without having to be prompted for a password (your keys: private key If you have created a passphrase for your private key (recommended), then you'd need to run the
Then the ssh-agent will be responsible for providing the passphrase for when you are using the private key (and importantly, the private key is protected by a passphrase and the passphrase is not stored in a file). | |||
|
feedback
|
|
Try to use ssh keys to authentication. See man ssh-keygen. This is more secure way. Use:
to disable interactivity. | |||||||||||
feedback
|
|
No you cant do that, sicne that then the password would be visible by any users on your system, as the command with its arugmetns are visible by a ps aux for example. If you need host A to ssh to host B without human intervention, then use pubkeys. Put the public key of host A onto host B and vice versa and they can then connect to each other without a password. | |||
|
feedback
|
|
You can do this using expect
You need to have expect installed on your system. | |||
|
feedback
|
|
You can also use a bit of software called sshpass. It exposes your password for anyone on your system, but no keys, no expect, and relatively simple to setup. You should probably get to the point where you have keys, but that's not always possible. | |||
|
feedback
|