Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Putty is set up to run like:

putty.exe -load mysession -l myuser -pw mypass

But it logs me in as myuser. For root access I need to type in the console:

sudo -i

Then it asks for my password again.

Is there a way to automate this in Putty, so I don't have to type sudo -i and the password ? I'd like to have root access on startup by default.

share|improve this question
    
Does putty.exe -load mysession -l root -pw rootpass work? –  kmort May 20 '13 at 12:26
    
Nope. I think it's because root doesn't have a password, so whatever I enter it appears to be incorrect –  melanie May 20 '13 at 18:03
    
Good Idea: give root a password (use passwd root). Bad Idea:, make sure root has SSH permission using ssh_config. See cyberciti.biz/faq/allow-root-account-to-use-ssh-openssh , but realize this makes your system insecure. –  kmort May 20 '13 at 18:28
    
This is just for a local dev server on my PC. I don't really care about security –  melanie May 20 '13 at 19:12
    
hey thanks, I've set up a password for root, and now I can log in automatically with the command you suggested above :) –  melanie May 20 '13 at 19:18
add comment

2 Answers

up vote 2 down vote accepted

In putty: On the Connection > Data page, you can set an auto login username, and

On the Connection > SSH page, you can set a remote command such as sudo -i or sudo su -

If you don't ever want to have to type your password once, set up your ssh keys.

share|improve this answer
    
Thanks. I've managed to set public keys and stuff, added that remote command, but it still asks for my password to gain root access –  melanie May 20 '13 at 17:59
    
Weird. I don't have keys set up in my instance of putty, so I did have to type in my password once, but once I typed it in (for login auth) it just dumped me to a root console, with the # prompt. I wonder where the difference comes from. same version of Ubuntu too. odd. –  Hurricane Hamilton May 20 '13 at 18:30
add comment

If you set up public key authentication, you can do it with a passphrase-less key if desired, but do note that this reduces security as anyone who can get their hands on the key file will be able to log in to your account (subject to any restrictions on key usage listed in ~/.ssh/authorized_keys). Depending on your actual usage and situation this may be a serious problem or it may be no problem at all.

When you set up a session for PuTTY, under Connection -> SSH you can specify a remote command to execute. There should be no reason why this could not be sudo -i.

It might also be possible to configure sudo to not require a password (for your account, or globally), but this will of course mean that anyone who can get their hands on a connected session will have complete access to the entire system just by doing a single sudo.

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.