Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am using Putty to connect to host xxxxxx. I want to produce a shell script in which I should give the command ssh user@yyyyyy along with my password instead of giving it when prompted.

share|improve this question
1  
Here is the answer link –  Ruban Savvy Dec 16 '13 at 6:11
    
@RubanSavvy That link goes over how to configure SSH keys, which is only tangential to the question. –  Chris Down Dec 16 '13 at 6:32
3  
This has the sound of an XY problem. Have you considered using SSH keys? If you're going to pass your password as an argument to a script, that argument will be visible to anyone by using ps. –  Patrick Dec 16 '13 at 7:06

2 Answers 2

This is an unsafe practice. You should never store your SSH password in plain text. Use an encrypted key.

The best-practice method is to use SSH keys.

$> putty.exe -ssh -i /path/to/private.pke user@host

PuTTYGEN.exe is the tool you use to generate the keys on Windows.

ssh-keygen is the tool you use to generate the keys on Linux.

Key-Based SSH Authentication

share|improve this answer

You can use this command putty.exe -ssh [email protected] -pw mypassword from cmd.

share|improve this answer
    
Can you use shell script in putty? –  Ruban Savvy Dec 16 '13 at 5:58
    
@RubanSavvy Putty is just the client, it doesn't run shell scripts. –  Chris Down Dec 16 '13 at 6:06
    
Before you run this command, you should add the path of putty.exe to your system environment path. Then you can use this command in both Windows Command Line or Powershell. BTW, why don't you just install ssh client in your devbox. Small suggestion, if you install git in windows, you can have a built-in ssh client. –  Rebornix Dec 16 '13 at 6:12
    
Hey I know that, BTW putty doesn't suits to the question. I was mentioning that @ChrisDown –  Ruban Savvy Dec 16 '13 at 6:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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