New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
ByteHosting - How to add SSH Keys?
Stationswift
Member
in Help
Hi, I'm a new customer to ByteHosting off this deal.
I wanted to be able to ssh with keys, but I'm having some trouble getting it all to work with my macbook air.
I have the keys in my ~/.ssh/ folder:

And have added the sites.key.pub to the VPS:

But when I try to mosh (SSH but more reliable on shoddy connections, uses ssh and works with keys as per this), I get asked for the password:

Can anyone help me with this? I'm new to the VPS world so sorry if this has been posted before or whatever.

Comments
According to the screenshots, you're trying to ssh using
root, when the key is apparently for yourstationswiftaccount?How would I change the key so that it's for
root@[server]?Sorry, I'm a little confused.
Do you have your key (
sites.key.pub) added in~/.ssh/known_hostson the remote server, where you're trying to connect to?I added the contents of
sites.key.pubin the VPS control panel, let me try adding it toknown_hostsreally quick and see if that fixes it.I think @DP meant that you're trying to login with the wrong account in your SSH command.
You don't need to change anything about the key, you need to change the user you're trying to login with, so change root@[server] to stationswift@[server] in your command and try again
stationswift is his macbook terminal I think.
He probably has to ticket in with ByteHosting to check if their template really added the key in.
I only have
root@[server]I never made the accountstationswift@[server], so that wouldn't work.I'll have to check that out. If it helps, this is the contents of

~/.ssh:Oops, sorry, I didn't mean
known_hosts, but yeah, theauthorized_keys, on the remote server.If the template isn't adding it, which is no surprise (sometimes), you can just add it in manually.
Do you see your key in the
authorized_keysfile?Here's the contents of
authorized_keys, looks just like whatsites.key.publooks likeYou might want to check
/var/log/auth.logor something.Just in case, have you tried
ssh -i ~/.ssh/sites.key.pub [email protected]?I appear to be getting a lot of failed auth attempts:
redacted_image
and
ssh -i ~/.ssh/sites.key.pub [email protected]fails with this error:redacted_image
Oh, sorry, what about
ssh -i ~/.ssh/sites.key [email protected]?You might want to change your SSH port too because strangers are at your front door
P.S. Redacted the images because your server IP was visible.
ssh -i ~/.ssh/sites.key [email protected]seems to have worked with no error. restarting now to test.EDIT: I still am being asked for my password on login.
Would fail2ban be worthwhile in leiu of changing my ssh port?
You mean your key passphrase?
It would be advisable to just change to a non-standard port and disable password authentication.
I am apparently illiterate, it logs me in with the passphrase. How would I automate the logging in with said key?
That's fair. I'll do that as well as install fail2ban for that extra security.
Thank you for the help thus far!
Considering the non-standard key name, I assume you have multiple keys in your
.sshfolder?In
.ssh/config, you can add:I don't. I just gave it a random-ish name when prompted. I appreciate the info on
.ssh/config, let me try that nowI believe that's why your
sshcommand didn't pick up the file when you attempted to connect to your server.If you only have one key, and if it was using the default/standard name(s) (
id_rsa/dsa/ecdsa/ed25519) ,sshwould've taken it, without needing to specify theIdentityFile.https://phoenixnap.com/kb/ssh-config
Got everything working + fail2ban, thanks for all the help!