Question

I got the below error, which I think is caused by my username having a space - for this example my name is "username Mark"

WARNING: Could not generate compute ssh key: 

Public key file (/Users/username Mark/.ssh/google_compute_engine.pub) doesn't contain an OpenSSH public key. The key must consist of exactly three space separated parts.
ssh-rsa AAAAB3NzaC1yc2EAAAADAL3LiXbkjcIlHo9j5L5Sw/Tr0W+mYQBq0/cCCdD1FiiRHtPN9vt8ZJ+TxtnRzOvn040BQnLWwGzxWt2LaAHWISHQJqF6Cd7AHuN9eypzoF85vxKMKL3LgabR+Mcdj3LKoH4jOF/xx6PvfA74SDnl/8N username Mark@Marks-MBook-Air.local

I tried editing the google_compute_engine.pub file to "username Mark"@Marks-MBook-Air.local but same error.

I then tried the solution by adding the username and host to the ssh config file as highlighted in this answer: scp on OSX doesn't allow spaces in usernames?

I used:

Host NBMark
User "username Mark"
Hostname Marks-MBook-Air.local

Which got me a little further, but then produced this error indicating it didn't workout (IP number altered):

Marks-MBook-Air:~ username Mark$ gcutil --service_version="v1beta14" --project="project-name" ssh --zone="europe-west1-a" "instance-test-2"
INFO: Updated project with new ssh key. It can take several minutes for the instance to pick up the key.
INFO: Waiting 300 seconds before attempting to connect.
INFO: Running command line: ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/username Mark/.ssh/google_compute_engine -A -p 22 username Mark@5.35.208.77 --
Warning: Permanently added '5.35.208.77' (RSA) to the list of known hosts.
Permission denied (publickey).

Is it possible to escape the space for authetication?

edit - I eventually managed to log in by renaming my shortname using this guide: http://www.macworld.com/article/1132693/changeshortusername.html

Yours faithfully, Mark

Was it helpful?

Solution 2

I got it working by avoiding the problem, renaming my "shortspace" name to have no space, following this guide: http://www.macworld.com/article/1132693/changeshortusername.html

Here are the steps to follow:

  1. If Automatic Login is enabled (in Accounts preferences) for the account you’re modifying, disable it. Similarly, if File Vault is enabled (in Security preferences), disable it. You can re-enable these features, if desired, after completing the procedure.

  2. Log in as a different user than the one you want to modify; make sure the account you want to modify is not logged in.

  3. Open the Accounts pane of System Preferences. If the lock icon in the lower-left of the Accounts window is “locked,” click on it and provide an administrative username and password; this allows you to make changes.

  4. In the list of accounts on the left, right-click (or Control-click) on the name of the account you want to modify; choose Advanced Options from the resulting menu. In the Advanced Options screen, delete your current short username in the Short Name field, and then type in your desired new short username. (Do not make any changes to the Home Directory field.) Click on OK and close System Preferences.

  5. Restart your Mac.

After restarting, your original short username will no longer be valid; you’ll need to use your new name exclusively. Mac OS X automatically updates any groups to which your account belongs, and changes the path to your personal Web Sharing directory (for example,

http://yourIPaddress/~newusername).

TIP: If after changing your account name, you find yourself occasionally typing your original username by accident, you can use the first procedure, above, to add your old name as an alias to your new one.

Advantages: Relatively safe; your actual short username is changed; avoids problems with preferences and applications that store settings based on the path to your home directory; Web Sharing directories reflect your new username.

Disadvantages: Doesn’t change the name of your home folder in the Finder or the name of File Sharing shares; can cause minor issues with preferences and application that store data or settings based on your short username.

OTHER TIPS

This might work on OSX it is not supported in GNU environment, this issue is not specific to ComputeEngine

see

adduser space\ indaname adduser: To avoid problems, the username should consist only of letters, digits, underscores, periods, at signs and dashes, and not start with a dash (as defined by IEEE Std 1003.1-2001). For compatibility with Samba machine accounts $ is also supported at the end of the username

use a username which satisfies the above criteria

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top