SFTP RSA authentication in Azure VM

徘徊边缘 提交于 2019-12-25 16:53:30

问题


Requirement- Connecting SFTP server from local windows machines using WinSCP with keys

Technical- I have Azure VM(Windows 2012 server R2) in which Cygwin64 is installed for SFTP. I want to connect SFTP server using RSA authentication i.e using keys.

I have edited the sshd_config file for RSA authentication. In cygwin64 folder I have also created .ssh folder and under that Authorized_keys file.

From local machine using putty I have generated Public and private keys and this public key I have entered in Authorized keys file but when I am trying to connect with that Private key it is saying "Server refused our key"


回答1:


I have entered in Authorized keys file but when I am trying to connect with that Private key it is saying "Server refused our key"

If you see this type of message, the first thing you should do is check your server configuration carefully. Common errors include having the wrong permissions or ownership set on the public key or the user’s home directory on the server.

Maybe you can follow those steps to setup CYGWIN authenticate with private key:
1.Install GYCWIN (OpenSSH and cygrunsrv)
2.configure sshd use this command ssh-host-config -y
3.Start SSHD service with this command cygrunsrv --start sshd
4.Add your public key to authorized_keys(we can copy public Key to this file):

jason@jasonvm ~/.ssh
$ ls -a
.  ..  authorized_keys  id_rsa  id_rsa.pub  id_rsa1  known_hosts
$ cat authorized_keys 
ssh-rsa AAAAB3Nxxx.......xxxxzaAVbeVFw==
jason@jasonvm ~/.ssh
$ pwd
/home/jason/.ssh

By the way, if you can't find this directory, you can use ssh-keygen.exe command to create this directory /home/user/.ssh, if you can't find this file authorized_keys, we should create it, and run this command chmod 600 authorized_keys

Afther that, we can use other Linux VM to SSH or SFTP this VM(we should open port 22 on Azure NSG inbound rules).
If you want to use winscp to login this VM, we should convert private key to .ppk. In this way, we can use this key to login this SFTP.

Note:
we can use winscp to convert .key to .ppk.

For test, you may try to use Putty to login azure vm with your private key, to make sure you are using the right private key and public key.

Update:
We can add open ssh and sftp like this:



来源:https://stackoverflow.com/questions/44188790/sftp-rsa-authentication-in-azure-vm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!