2

This question already has an answer here:

The situation:

  • I have an IP : 192.168.1.1 $IP
  • username : root (or whatever) $USER
  • and a passwd: foo $PASSWD

Is there a way to give $PASSWD to ssh ? like

 PASSWORD_VAR=$PASSWD ssh -l $USER $IP
  • user can see the password,
  • user must "land" on usual interactive shell session.
  • somme package might be installed on desktop linux if need be.

reading ssh(1) give me no clues. such thing exists in window's world (e.g. Kitty), now I would like to do the same in unix (suse or unbuntu if that matter).

I know how to set up public/private key pair, but this is off topic.

marked as duplicate by Gilles ssh Feb 25 '15 at 22:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

It is possible if you can install sshpass, so you can run:

sshpass -p 'password' ssh 192.168.1.1
1

ssh by default and by design doesn't do it. This is because clear text passwords embedded in scripts is pretty fundamentally a bad idea. Not least because - if it's specified on a single command line, it normally shows up in the ps list that every user can see. So it's deliberately made difficult, to encourage better habits. public-private key pairs and ssh-agent go a long way to removing the requirement.

If you've really a need, then expect can do it:

#!/usr/bin/expect -f

spawn /usr/bin/ssh -n username@hostname 
expect "password:"
send "Password\n";
interact

(Or sshpass as the other commentator has mentioned).

Not the answer you're looking for? Browse other questions tagged or ask your own question.