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.

I am trying to ssh into my server from the command-line without including the username in the url. I do not want it to send any username, as it currently takes the active account and sends that as user.

ex: ssh server.com -> (doesn't send default username)

instead of username@server.com

I would want to input username directly into the server, just like it is done using putty on windows.

As birryree said:
Oh I get it...he wants to be prompted for a username, rather than having to provide one when connecting - but I don't really see the utility in such a thing. – birryree Sep 8 at 17:41

share|improve this question

migrated from stackoverflow.com Sep 12 '11 at 4:59

This question came from our site for professional and enthusiast programmers.

    
I would want to input username directly into the server - what? Putty just saves a configuration so it knows what user to use, if you configure it that way. –  birryree Sep 8 '11 at 17:34
    
Yup, SSH is done on a user account basis as far as I know so if you connect without a user how can the server authenticate you? –  Clive Sep 8 '11 at 17:36
1  
Oh I get it...he wants to be prompted for a username, rather than having to provide one when connecting - but I don't really see the utility in such a thing. –  birryree Sep 8 '11 at 17:41
    
that can't be done from the server side. –  jgr Sep 8 '11 at 17:43
    
Is there a particular reason you want to do this other than personal preference? i.e., you want to hide the username in the process list or something like that. –  evil otto Sep 8 '11 at 17:51
show 4 more comments

3 Answers

You would have to write a wrapper script for ssh.

#!/bin/bash
HOST=$1

read -p "user: " USER
ssh -l $USER $HOST

then use that wrapper script i.e ./ssh-wrapper hostname

I see no point in this but thats what you'd have to do.

share|improve this answer
    
Doesn't this still require the username to be on the client machine? I want to be prompted by the server for it. –  TheRealKingK Sep 14 '11 at 4:28
add comment

In ~/.ssh/config:

host shortname
hostname long.name.tld
user your-username

Then you can type ssh shortname and it will login as your-username

share|improve this answer
add comment

You can use:

sudo ssh <thehost>

The sudo will authenticate you with the local machine only, and on the remote machine, it will look like

root@<thehost>
share|improve this answer
    
This is very interesting, but I don't want to log in as root. I want to be prompted for username by the server. –  TheRealKingK Sep 14 '11 at 4:40
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.