By k0r3n
I’m working on a Virtual Machine where I have Ubuntu Server, in that server I connect to my Droplet (Ubuntu as well), via ssh , but when I tried to login with this syntax:
ssh subdomain.mydomain.com
It brings this error :
Permission denied (publickey)
But If I use any of this syntax:
ssh my_user@subdomain.mydomain.com
ssh my_user@Droplet_IP
I login without a problem. So I was just wondering If the first syntax is wrong or I have something messed up within sshd_config file or my Droplet firewall service configuration (just my IP can access to my droplet).
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
The short answer is… you can configure the ssh client with a simple text file located here:
~/.ssh/config
(~ is a shortcut to your Ubuntu VM user’s home directory)
Inside that file these lines would provide the behavior you want:
Host subdomain.mydomain.com
User my_user
Just as an aside, the /etc/ssh/sshd_config manages the SSH service running on an ubuntu server, not the ssh client you use to connect to one. /etc/ssh/ssh_config (no d in the filename) does allow you set global options for the ssh client to use but more typical in these cases is the per-user config mentioned above.
Hello, @k0r3n
If you use the ssh command without specifying the user a session will be created with the user that is currently in use on your Virtual Machine. This is the reason this works fine when you specify the username.
You can follow up the example above which or simply create an alias in your .bashrc profile for quick access.
You can open the file with any text editor:
sudo nano ~/.bashrc
and add the following line:
alias dropletssh='ssh my_user@Droplet_IP'
Save the file and exit. Then simply reload the .bashrc profile with this command:
source ~/.bashrc
Now if your type dropletssh in the command line (terminal) you will connect to your droplet.
Hope that this helps! Regards, Alex
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.