2

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.

5
  • Does putty.exe -load mysession -l root -pw rootpass work?
    – kmort
    Commented May 20, 2013 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
    Commented May 20, 2013 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
    Commented May 20, 2013 at 18:28
  • This is just for a local dev server on my PC. I don't really care about security
    – melanie
    Commented May 20, 2013 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
    Commented May 20, 2013 at 19:18

2 Answers 2

5

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.

2
  • 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
    Commented May 20, 2013 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. Commented May 20, 2013 at 18:30
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .