Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
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.

ByteHosting - How to add SSH Keys?

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

  • DPDP Administrator, The Domain Guy

    According to the screenshots, you're trying to ssh using root, when the key is apparently for your stationswift account?

  • @DP said:
    According to the screenshots, you're trying to ssh using root, when the key is apparently for your stationswift account?

    How would I change the key so that it's for root@[server]?

  • DPDP Administrator, The Domain Guy

    @Stationswift said:

    @DP said:
    According to the screenshots, you're trying to ssh using root, when the key is apparently for your stationswift account?

    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_hosts on the remote server, where you're trying to connect to?

  • Sorry, I'm a little confused.

    Do you have your key (sites.key.pub) added in ~/.ssh/known_hosts on the remote server, where you're trying to connect to?

    I added the contents of sites.key.pub in the VPS control panel, let me try adding it to known_hosts really quick and see if that fixes it.

  • CloudHopperCloudHopper Member
    edited November 2024

    @Stationswift said:

    @DP said:
    According to the screenshots, you're trying to ssh using root, when the key is apparently for your stationswift account?

    How would I change the key so that it's for root@[server]?

    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

  • FatGrizzlyFatGrizzly Member, Host Rep

    @DP said:

    @Stationswift said:

    @DP said:
    According to the screenshots, you're trying to ssh using root, when the key is apparently for your stationswift account?

    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_hosts on the remote server, where you're trying to connect to?

    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.

    Thanked by 1CloudHopper
  • @CloudHopper said:

    @Stationswift said:

    @DP said:
    According to the screenshots, you're trying to ssh using root, when the key is apparently for your stationswift account?

    How would I change the key so that it's for root@[server]?

    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

    I only have root@[server] I never made the account stationswift@[server], so that wouldn't work.

    @FatGrizzly said:

    @DP said:

    @Stationswift said:

    @DP said:
    According to the screenshots, you're trying to ssh using root, when the key is apparently for your stationswift account?

    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_hosts on the remote server, where you're trying to connect to?

    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'll have to check that out. If it helps, this is the contents of ~/.ssh:
    image

  • DPDP Administrator, The Domain Guy
    edited November 2024

    Oops, sorry, I didn't mean known_hosts, but yeah, the authorized_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_keys file?

  • @DP said:
    Oops, sorry, I didn't mean known_hosts, but yeah, the authorized_keys, on the remote server.

    If the template isn't adding it, which is no surprise (sometimes), you can just add it in manually.

    Here's the contents of authorized_keys, looks just like what sites.key.pub looks like

    image

  • DPDP Administrator, The Domain Guy

    @Stationswift said:

    @DP said:
    Oops, sorry, I didn't mean known_hosts, but yeah, the authorized_keys, on the remote server.

    If the template isn't adding it, which is no surprise (sometimes), you can just add it in manually.

    Here's the contents of authorized_keys, looks just like what sites.key.pub looks like

    image

    You might want to check /var/log/auth.log or something.

    Just in case, have you tried ssh -i ~/.ssh/sites.key.pub [email protected]?

  • StationswiftStationswift Member
    edited November 2024

    @DP said:

    @Stationswift said:

    @DP said:
    Oops, sorry, I didn't mean known_hosts, but yeah, the authorized_keys, on the remote server.

    If the template isn't adding it, which is no surprise (sometimes), you can just add it in manually.

    Here's the contents of authorized_keys, looks just like what sites.key.pub looks like

    image

    You might want to check /var/log/auth.log or 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

  • DPDP Administrator, The Domain Guy
    edited November 2024

    @Stationswift said:

    @DP said:

    @Stationswift said:

    @DP said:
    Oops, sorry, I didn't mean known_hosts, but yeah, the authorized_keys, on the remote server.

    If the template isn't adding it, which is no surprise (sometimes), you can just add it in manually.

    Here's the contents of authorized_keys, looks just like what sites.key.pub looks like

    image

    You might want to check /var/log/auth.log or 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 :smiley:

    P.S. Redacted the images because your server IP was visible.

  • StationswiftStationswift Member
    edited November 2024

    @DP said:

    @Stationswift said:

    @DP said:

    @Stationswift said:

    @DP said:
    Oops, sorry, I didn't mean known_hosts, but yeah, the authorized_keys, on the remote server.

    If the template isn't adding it, which is no surprise (sometimes), you can just add it in manually.

    Here's the contents of authorized_keys, looks just like what sites.key.pub looks like

    image

    You might want to check /var/log/auth.log or 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:
    image

    and ssh -i ~/.ssh/sites.key.pub [email protected] fails with this error:
    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 :smiley:

    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?

  • DPDP Administrator, The Domain Guy

    @Stationswift said: EDIT: I still am being asked for my password on login.

    You mean your key passphrase?

    @Stationswift said: Would fail2ban be worthwhile in leiu of changing my ssh port?

    It would be advisable to just change to a non-standard port and disable password authentication.

  • @DP said:

    @Stationswift said: EDIT: I still am being asked for my password on login.

    You mean your key passphrase?

    @Stationswift said: Would fail2ban be worthwhile in leiu of changing my ssh port?

    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?

    It would be advisable to just change to a non-standard port and disable password authentication.

    That's fair. I'll do that as well as install fail2ban for that extra security.

    Thank you for the help thus far!

  • DPDP Administrator, The Domain Guy
    edited November 2024

    @Stationswift said: I am apparently illiterate, it logs me in with the passphrase. How would I automate the logging in with said key?

    Considering the non-standard key name, I assume you have multiple keys in your .ssh folder?

    In .ssh/config, you can add:

    Host <whatever_name>
    Hostname <ip>
    Port <whatever_port>
    IdentityFile ~/.ssh/sites.key
    
  • @DP said: Considering the non-standard key name, I assume you have multiple keys in your .ssh folder?

    I don't. I just gave it a random-ish name when prompted. I appreciate the info on .ssh/config, let me try that now

    Thanked by 1DP
  • DPDP Administrator, The Domain Guy
    edited November 2024

    @Stationswift said: I don't. I just gave it a random-ish name when prompted.

    I believe that's why your ssh command 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) , ssh would've taken it, without needing to specify the IdentityFile.

    @Stationswift said: I appreciate the info on .ssh/config, let me try that now

    https://phoenixnap.com/kb/ssh-config

    Thanked by 1Stationswift
  • @DP said:

    @Stationswift said: I don't. I just gave it a random-ish name when prompted.

    I believe that's why your ssh command 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) , ssh would've taken it, without needing to specify the IdentityFile.

    @Stationswift said: I appreciate the info on .ssh/config, let me try that now

    https://phoenixnap.com/kb/ssh-config

    Got everything working + fail2ban, thanks for all the help!

    Thanked by 1DP
Sign In or Register to comment.