MySQL workbench SSH connection error [Bad authentication type(allowed_types=['publickey'])] - mysql-workbench

I have issue regarding SSH connection with my server. When i try to connect it results into error:"Bad authentication type(allowed_types=['publickey'])"
Thanks

You need to ensure that your private key is in openssh format. With puttygen you can export as Openssh. This worked for me.

Check your username and public key this can cause problem.
Attach the private key file with extension .ppk
Also verify your connection with putty.
Also check for the restriction on server.

FYI, my company uses a Yubikey and so the SSH part can be a bit mysterious. However, walking through a shell login with the yubikey yinit command, to ssh to IP (no password needed here), and finally to connecting mysql (still shell), I attempted to MySQL Workbench a few times with my different passwords to no avail.
Finally, I noticed the "SSH Key File" field and looked up where my .ssh file was -- /Users/myProfile/.ssh/
Set the "id_rsa.pub" file as it and voila!
Everything worked.

Related

How to save ssh password to vscode?

I am using vscode to connect to a remote host. I use Remote-SSH (ms-vscode-remote.remote-ssh) extension to do so. Every time I want to connect to the remote host, I need to enter the password.
Is there a way to save the ssh password to vscode?
To setup password-less authentication for ssh on Visual Studio Code, perform the following steps.
These examples assume the following (replace with your actual details)
Host: myhost
Local User: localuser
Remote User: remoteuser
Remote User Home Dir: remoteuserhome
SSH Port: 22
I'm using a Mac so Windows will be a bit different but the basics are the same
Tell VS Code and your machine in general how you will be connecting to myhost
Edit:
/Users/<localuser>/.ssh/config
Add:
Host <myhost>
HostName <myhost>
User <remoteuser>
Port 22
PreferredAuthentications publickey
IdentityFile "/Users/<localuser>/.ssh/<myhost>_rsa"
Next generate a public and a private key with something like OpenSSL
ssh-keygen -q -b 2048 -P "" -f /Users/<localuser>/.ssh/keys/<myhost>_rsa -t rsa
This should make two files:
<myhost>_rsa (private key)
<myhost>_rsa.pub (public key)
The private key (<myhost>_rsa) can stay in the local .ssh folder
The public key (<myhost>_rsa.pub) needs to be copied to the server (<myhost>)
I did it with FTP but you can do it however you wish but it needs to end up in a similar directory on the server.
ON THE SERVER
There is a file on the server which has a list of public keys inside it.
<remoteuserhome>/.ssh/authorized_keys
If it exists already, you need to add the contents of <myhost>_rsa.pub to the end of the file.
If it does not exist you can use the <myhost>_rsa.pub and rename it to authorized_keys with permissions of 600.
If everything goes according to plan you should now be able to go into terminal and type
ssh <remoteuser>#<myhost>
and you should be in without a password. The same will now apply in Visual Studio Code.
Let's answer the OP's question first:
How to 'save ssh password'?
Since there is no such thing as "ssh password", the answer to "how to save the remote user password" is:
This is not supported by VSCode.
VSCode proposes to setup an SSH Agent in order to cache the passphrase (in case you are using an encrypted key)
But if the public key was not properly registered to the remote account ~/.ssh/authorized_key, SSH daemon will default to the remote user credentials (username/password).
It is called PasswordAuthentication, often the remote user password.
And caching that password is not supported for SSH sessions.
It is only supported by a Git credential helper, when using HTTPS URLs.
(it defers to the OS underlying credential manager)
But I don't know of a remote user password cache when SSH is used.
As Chagai Friedlander comments, the answer to the original question is therefore:
No, but you can use SSH keys and that is better.
Speaking of SSH keys:
"ssh password": Assuming you are referring to a ssh passphrase, meaning you have created an encrypted private key, then "saving the ssh password" would mean caching that passphrase in order to avoid entering it every time you want to access the remote host.
Check first if you can setup the ssh-agent, in order to cache the passphrase protecting your private key.
See "VSCode: Setting up the SSH Agent"
This assumes you are using an SSH key, as described in "VSCode: Connect to a remote host", and you are not using directly the remote user password.
Using an SSH key means its public key would have been registered to the remote account ~/.ssh/authorized_keys file.
This section is the workaround the OP ended up accepting: registering the public key on the remote user account, and caching the local private key passphrase worked.
For those trying to connect through Vscode Remote SSH Extension steps provided at https://code.visualstudio.com/docs/remote/troubleshooting#_ssh-tips)
For Windows(Host) --> Linux(Remote)
Create an SSH .pub key in your windows ssh-keygen -t rsa -b 4096
Copy the contents of the .pub key (default path C:\Users\username/.ssh/id_rsa.pub)
SSH into Remote machine and append the contents of the pub key in authorized keys echo "pub-key" >> ~/.ssh/authorized_keys

VSCode Remote SSH cannot identify private key file

Been trying to solve this for hours already. Already searched the net and follow tutorials but nothing is working.
In my Windows local machine I installed Remote SSH plugin in VSCode. I'm trying to connect to my remote linux server.
My config file looks like this (changed hostname and user to dummy values for security).
Host RemoteServer
HostName remote.server.infra
User user123
IdentityFile ~/.ssh/privkey
When trying to connect to New Host. It keeps prompting for password.
As per checking the logs it is saying
no such identity: C:\\Users\\user123/.ssh/privkey: No such file or directory
This privkey file is the exact file I'm using in my putty when connecting to remote server.
What am I missing?
EDIT:
Finally figured it out. I had to convert my private key to openssh format with puttygen.
In addition of using an openSSH format, I would also put the full path in the config file:
Host RemoteServer
HostName remote.server.infra
User user123
IdentityFile /c/Users/user123/.ssh/privkey
Note that the SSH URL then becomes:
ssh -Tv RemoteServer
Note: Başar Söker adds in the comments:
I also needed to add a colon to my path.
Here how it looks like:
IdentityFile /c:/Users/username/.ssh/privatekey.pem
Note: reukiodo adds in the comments:
If you copy/paste the private key, it MUST end with a newline, or it will also result in this same error.
Reminder: only the public key can be copied elsewhere. The private key should remain on your computer.
if you have generated public private key pair using putty you need to convert the private key using putty generation conversion or else it will not work and it will show public key access denied

VSCode remote developement using ssh with passphrase protected ssh-key

I have a remote ssh server on which I want to do remote developement.
My public key is added to the authorized keys on the server and my private key is passphrase protected.
I added the remote host as described here using ssh user#host -i ~/.ssh/key
But whenever I try to open a new VSCode window on the remote host it fails and I see in the log that the connection timed out, which is expected because I don't get asked for my private-key passphrase.
I read this post on remote development using ssh and I searched on google but couldn't find any hints to what I could do to enable/enter ssh-key passphrase while connecting to remote host.
I know I can connect to the remote using a non-passphrase-protected key but I'm not asking for that, I want to know if it's possible to connect to a remote host from VSCode using a passphrase protected key.
If your key is not the default one, that means you need a ~/.ssh/config entry in which you specify your SSH connection parameters:
Host myserver
Hostname host
User user
IdentityFile ~/.ssh/key
The Visual Studio Code Remote Development will automatically read the config file, and when you ask for opening an SSH session, you will see "myserver" entry: if you select it, the SSH session opened will use ~/.ssh/key, the right private key.
Then, as long as your ssh-agent is enabled, and you have entered at least once your passphrase (through a manual ssh myserver), VSCode will use the same agent to get the passphrase when it will need it.
This is what solved it for me, your issue could be different.
In VScode, choose command: Remote-SSH: Open SSH Configuration File...
Choose the location that is offered to you (or create a config file without extension to desired location), for example:
C:\Users\[USER_NAME]\.ssh\config. Make sure you have appropriate permissions.
Prepare you configuration file, for example
Host Custom_Name
HostName example.server.com
User your_user_name
IdentityFile C:\Users\[USER_NAME]\Documents\MobaXterm\home\.ssh\id_rsa
(or wherever you have the private key)
Finally add a custom path to your configuration file. This is what I lacked for long time
{
// add custom configuration file path
"remote.SSH.configFile": "C:\\Users\\[USER_NAME]\\.ssh\\config",
// Other settings
// omit comma after *config"* if that is your last setting
}
Now it should ask for passphrase as opposed to password.
P.S. Here is a lot of useful information with the setup, especially with the keys that I have omitted for brevity.

RubyMine - cannot login to the github.com using given credentials

I have installed RubyMine on OS X and Windows 7, and neither can connect to GitHub.
Both computers have SSH configured and can connect to GitHub using SSH on the commandline.
Both give me the same error when attempting to configure GitHub in Preferences:
Is this a known issue, or is there something else I need to configure?
Make sure you've specified key and its password propely, note that the key file must be in OpenSSH format. You can convert it using puttygen.exe on Windows or ssh-keygen on Mac.
Usually you would log into GitHub with your email address and password, but for RubyMine you need to provide you username (not email) and password.
If your SSH keys are valid then you should not have any issues logging in.

Connect Eclipse RSE with remote Linux server using public key attained from Amazon ec2

I want a easy way to save, copy and edit files on a remote server. I'm using Eclipse as an IDE, what could be better for these tasks than RSE(Remote System Exlporer) plugin for Eclipse. The thing is that I dont know how to make a connection using a public key. I have file that I downloaded from my Amazon account, *.pem. But I don't see any forms or inputs for this, when I try to connect to my remote Linux server. It is just User-id and password. I also tried to open the public key using the system's text editor and copy everything to my password field, but it didn't worked. Pls help me
this was baking my noodle for a while too. you put the keys in a folder not in the RSE config but in the whole of eclipse
check this: http://siteadmin.gforge.inria.fr/eclipse-ssh.html
Not mentioned (at least in explicitly) is the fact that RSE (and for what I've seen, Eclipse in general) only seems to work with 1024 bit keys https://bugs.eclipse.org/bugs/show_bug.cgi?id=404714
I also had issues, because my privatekey was 2048, but I added a new key to authorized hosts and then I could connect.
I added my local computer's ~/.ssh/id_rsa.pub to the remote /home/ec2-user/.ssh/authorized_keys.
Then just set the user to connect in RSE to ec2-user when connecting.
Someone asked for root login. It works too: update /root/.ssh/authorized_keys, and edit /etc/ssh/sshd_config to allow root login:
#PermitRootLogin forced-commands-only
PubkeyAuthentication yes
Then reload the sshd daemon: service sshd restart