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-id
is 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_keys
file has insufficient permissions1.You can try to fix this issue by enabling password login in the
sshd_config
file. To do this, open the file in a text editor and find thePasswordAuthentication
line and make sure it ends withyes
. Find theChallengeResponseAuthentication
option 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 sshd
1.Would you like more information on this topic?
The
sshd_config
file is usually located at/etc/ssh/sshd_config
1. TheChallengeResponseAuthentication
option is located within this file. You can open the file in a text editor and find theChallengeResponseAuthentication
line to make changes1.Is there anything else you would like to know?
You can use the
find
command to search for thesshd_config
file in your Linux system. Here’s an example command that searches for the file in the/etc
directory:Copy
This command will return the path of the
sshd_config
file if it is located within the/etc
directory. You can also search in other directories by replacing/etc
with 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_config
file. This file is usually owned by theroot
user and only users withsudo
orroot
privileges 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
PasswordAuthentication
option in thesshd_config
file to enable password authentication for SSH.Is there anything else you would like to know?
If the
PasswordAuthentication
option is set toyes
in thesshd_config
file 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
username
with your username on the remote server andremote_server_ip
with 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
PasswordAuthentication
is set tono
on 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_keys
file 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
~/.ssh
directory. You can then copy the public key to the remote server using thessh-copy-id
command:Copy
Replace
username
with your username on the remote server andremote_server_ip
with the IP address of the remote server. This command will add your public key to theauthorized_keys
file on the remote server.Once your public key has been added to the
authorized_keys
file on the remote server, you can log in via SSH without entering a password. Thessh
command will use your private key to authenticate you automatically.Is there anything else you would like to know?
It seems that the
ssh-copy-id
command 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-id
is 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
cat
command: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
username
with your username on the remote server andremote_server_ip
with 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_keys
file in a text editor:nano ~/.ssh/authorized_keys
Copy
This command will open the
authorized_keys
file in thenano
text editor. You can use a different text editor if you prefer.authorized_keys
file and save the changes.After adding your public key to the
authorized_keys
file 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?