Azure VM中的SFTP RSA身份验证 [英] SFTP RSA authentication in Azure VM

查看:113
本文介绍了Azure VM中的SFTP RSA身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要求-使用WinSCP和密钥从本地Windows计算机连接SFTP服务器

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

技术-我有Azure VM(Windows 2012服务器R2),其中为SFTP安装了Cygwin64. 我想使用RSA身份验证(即使用密钥)连接SFTP服务器.

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.

我已经编辑了用于RSA身份验证的sshd_config文件.在cygwin64文件夹中,我还创建了.ssh文件夹,并且在该Authorized_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"

推荐答案

我已经输入了授权密钥文件,但是当我尝试连接时 用那个私钥说服务器拒绝了我们的密钥"

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.

也许您可以按照以下步骤设置使用私钥进行CYGWIN身份验证:
1. 安装 GYCWIN(OpenSSH和cygrunsrv)
2. 配置 sshd使用此命令ssh-host-config -y
3.使用此命令cygrunsrv --start sshd
启动 SSHD服务. 4.将公钥添加到authorized_keys(我们可以将公钥复制到此文件):

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

顺便说一句,如果找不到此目录,则可以使用ssh-keygen.exe命令创建该目录/home/user/. ssh ,如果找不到该文件authorized_keys,我们应该创建它并运行此命令chmod 600 authorized_keys

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

此外,我们可以使用其他Linux VM对该VM进行SSH或SFTP(我们应在Azure NSG入站规则上打开端口22).
如果要使用winscp登录此VM,则应将私钥转换为.ppk.这样,我们可以使用此密钥登录此SFTP.

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.

注意:
我们可以使用winscp将.key转换为.ppk.

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

为了进行测试,您可以尝试使用Putty通过私钥登录azure vm,以确保使用正确的私钥和公钥.

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.

更新:
我们可以像这样添加打开的ssh和sftp:

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

这篇关于Azure VM中的SFTP RSA身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆