If I'm connecting to an ssh server and I noticed I made a mistake in the username, how do I cancel the session when the server is prompting me for password?

The only way I know is to press ctrl-c to kill the ssh process, is there a better way?

I don't necessarily need to cancel the session, just change the username.

link|improve this question
feedback

4 Answers

up vote 7 down vote accepted

You can't.

Come 'on, I mean really - just do it again - it's really not that bad. =)

link|improve this answer
haha, alright. I just thought I might be missing something obvious. – hasen j May 28 '09 at 17:35
feedback

Don't type the username to begin with. Just type the hostname. If your username is different on the remote host, put the username in your .ssh/config like so.

Host hostname
User remote_username

While you're at it, configure ssh keys so you don't have to put in your password.

link|improve this answer
feedback

I'm pretty sure there isn't a way to do that. If you feel masochistic and launch the sshd daemon on the server side in userspace with debug logging turned on, you'll see it. I don't have any log examples to hand, but what it does is take the username and anything after that is used to authenticate the username. The only way to change the username is to terminate the session and reconnect. You only get one shot per session.

link|improve this answer
feedback

Changing username during the authentication phase is not supported in anything less than SSH 2. Most SSH clients however do not support this feature of the protocol (I have yet to find one that actually does).

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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