Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a situation where I need to have PuTTY (or another SSH client for Windows) automatically log into another machine via SSH. I realize that this isn't a good idea security-wise, but unfortunately I'm constrained by the limitations both on the client and the server.

The best solution would be to have a shortcut or script on the desktop that, when double clicked, will connect to the server and automatically log in. Can I do this with PuTTY?

I am willing to explore public key authentication, but I'm not sure where the PuTTY key resides or how to copy it to the server, as the app starts automatically upon login.

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

You will do:

putty user@host -pw password

Notice that using public-key authentication is safer and preferred.

share|improve this answer
    
I can't seem to get it to work - I get back unknown option "pw:<password>" –  Kyle Cronin May 11 '09 at 20:48
    
Corrected syntax. The password option is -pw and not -pw: –  user1797 May 11 '09 at 20:54
    
Excellent, that works! –  Kyle Cronin May 11 '09 at 20:57
add comment

You should use SSH keys instead. You can have those passwordless too. Its not a good idea either, but it's a lot better than saving passwords in scripts.

You generate a key with putty-gen, and save it where ever you like. Then you create a profile in putty.exe and attach that key to it.

When you want to start with that profile:

putty.exe -load <profilename>
share|improve this answer
    
You have the general idea, but your instructions are incorrect. You might want to consider revising it to fully explain public-key authentication creation and use with putty, or link to a site that has all the details, like I did. –  user1797 May 11 '09 at 20:58
    
I've gone with a hybrid of both your answers - loading a profile with the window settings and using -pw to specify a password. Unfortunately, I can only award one accepted answer, but I still voted yours up. –  Kyle Cronin May 11 '09 at 21:10
    
@David: You're probably right. On the other hand, I pointed him in the correct direction. You just pointed the mans gun on his foot :( I don't think that "wrong" questions need to be answered to the letter. –  Commander Keen May 11 '09 at 21:11
    
@Keen, I answered to what he asked. It is not the preferred way (and I said so), but putty's author thought of it to be handy enough, so he coded it in putty. –  user1797 May 11 '09 at 21:21
    
I think it's a bit harsh to characterize hard-coding passwords into script/shortcuts as pointing a gun at my foot - there are definitely legitimate reasons for doing this, and my situation counts as one. –  Kyle Cronin May 11 '09 at 21:35
add comment

abandon putty if you need to store passwords such as remote ssh access to management consoles where you can't drop keys into the firmware image etc. i can think of 4 scenarios where you can't use keys and putty gets in your way and slows you down.

share|improve this answer
add comment

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.