putty serial autologin

I want to login to putty automatically via serial port through shell or bash script. This is the code:

#!/bin/bash
tty=/dev/$(dmesg | grep tty | tail -n 1 | sed -e 's/ /\n/g' -e 's/\t/\n/g' | grep tty)
tty=${tty%:}
sudo chown "$USER":"$USER" "$tty"
putty -serial "$tty" -sercfg 115200

But if I change the last line of code to:

putty -serial "$tty" -sercfg 115200 -l $username -pw $password

I get the following output:

PuTTY: the -pw option can only be used with the SSH protocol

Is there an alternative command, always via Putty, always via serial port?

1 Answer

No, you cannot pass a password when logging in over a serial line. Over a serial line, you are logged by a process that is called [a]getty and it will display a prompt for a username and a password.

Now, (because this PuTTY question appears off-topic to me) if you'd like to ask whether you could have a user 'logged in' at a serial port at all times without password, that answer is yes. Take a look at man agetty and search for -autologin.

Securty caveat: Needless to say that 'anyone' who is able to connect to your RS232 port with a dumb serial terminal (emulator), now gets in right away?

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like