If cannot ssh to remote server with password, it is possibly because that the remote server does not enable PasswordAuthentication.
So we need to use the method of public keys to login.
Run in Local Machine:
ssh-keygen
This will generate a key pair for ssh.
Then copy the public to remote server.
Run in Local Machine:
- Normally,
ssh-copy-idis available in Git console.
ssh-copy-id <username>@<remote_server>
After steps above, we could login remote server with the following command:
- Do not forget to specify
<username>@
ssh <username>@<remote_server>
Or if use a config file (C:\Users\xxx\.ssh\config) for ssh, you need to add the User <username> entry:
Host <server>
HostName <server_name>
User <username>
Bing Chat History
The “Permission denied (publickey,gssapi-with-mic,keyboard-interactive)” error appears after permission-related settings are modified on the SSH server. One reason for the error may be
sshd_config, the file that contains SSH server configuration. The other possibility is that theauthorized_keysfile has insufficient permissions1.You can try to fix this issue by enabling password login in the
sshd_configfile. To do this, open the file in a text editor and find thePasswordAuthenticationline and make sure it ends withyes. Find theChallengeResponseAuthenticationoption and disable it by addingno. If lines are commented out, remove the hash sign#to uncomment them. Save the file and exit. Restart the SSH service by typing the following command:sudo systemctl restart sshd1.Would you like more information on this topic?
The
sshd_configfile is usually located at/etc/ssh/sshd_config1. TheChallengeResponseAuthenticationoption is located within this file. You can open the file in a text editor and find theChallengeResponseAuthenticationline to make changes1.Is there anything else you would like to know?
You can use the
findcommand to search for thesshd_configfile in your Linux system. Here’s an example command that searches for the file in the/etcdirectory:Copy
This command will return the path of the
sshd_configfile if it is located within the/etcdirectory. You can also search in other directories by replacing/etcwith the path of the directory you want to search in.Is there anything else you would like to know?
If you are not an administrator on the Linux system, you will not have permission to modify the
sshd_configfile. This file is usually owned by therootuser and only users withsudoorrootprivileges can modify it.In this case, you will need to contact the system administrator and request that they make the change for you. They will be able to modify the
PasswordAuthenticationoption in thesshd_configfile to enable password authentication for SSH.Is there anything else you would like to know?
If the
PasswordAuthenticationoption is set toyesin thesshd_configfile on the remote server, you can log in to your user account via SSH using your username and password. Here’s an example command that you can use to log in:Copy
Replace
usernamewith your username on the remote server andremote_server_ipwith the IP address of the remote server. After running this command, you will be prompted to enter your password. Once you enter your password, you will be logged in to your user account on the remote server.Is there anything else you would like to know?
If
PasswordAuthenticationis set tonoon the remote server, you will not be able to log in via SSH using a password. Instead, you will need to use public key authentication.To use public key authentication, you will need to generate a key pair on your local machine and add the public key to the
authorized_keysfile on the remote server. Here’s an example of how you can generate a key pair on your local machine:Copy
This command will generate a new key pair and save it in the
~/.sshdirectory. You can then copy the public key to the remote server using thessh-copy-idcommand:Copy
Replace
usernamewith your username on the remote server andremote_server_ipwith the IP address of the remote server. This command will add your public key to theauthorized_keysfile on the remote server.Once your public key has been added to the
authorized_keysfile on the remote server, you can log in via SSH without entering a password. Thesshcommand will use your private key to authenticate you automatically.Is there anything else you would like to know?
It seems that the
ssh-copy-idcommand is not available on your system. This command is usually included with the OpenSSH package, but it may not be installed on all systems.If
ssh-copy-idis not available on your system, you can manually copy your public key to the remote server. Here’s an example of how you can do this:On your local machine, display the contents of your public key file using the
catcommand:cat ~/.ssh/id_rsa.pub
Copy
This command will display the contents of your public key file. Select and copy the entire key to your clipboard.
Log in to the remote server via SSH using your username and password:
ssh username@remote_server_ip
Copy
Replace
usernamewith your username on the remote server andremote_server_ipwith the IP address of the remote server. After running this command, you will be prompted to enter your password.Once you are logged in to the remote server, open the
authorized_keysfile in a text editor:nano ~/.ssh/authorized_keys
Copy
This command will open the
authorized_keysfile in thenanotext editor. You can use a different text editor if you prefer.authorized_keysfile and save the changes.After adding your public key to the
authorized_keysfile on the remote server, you should be able to log in via SSH without entering a password.Is there anything else you would like to know?