windows免密码登陆sftp

  1. 生成SSH密钥
    windos下通过SecureCrt生成的秘钥
    windows免密码登陆sftp_第1张图片
    选择秘钥格式
    windows免密码登陆sftp_第2张图片
    通行短语可选
    windows免密码登陆sftp_第3张图片
    选择openSSH秘钥格式
    windows免密码登陆sftp_第4张图片
  2. 配置linux服务器端

(1)将Identity.pub公钥文件上传至服务端的home/用户名/.ssh目录下
scp Identity.pub 用户名@服务端IP:/home/用户名/.ssh
(2)添加秘钥
将Identity.pub内容添加到authorized_keys中,如果不存在,就新建并且设置权限

cat Identity.pub >> authorized_keys
chmod 600 authorized_keys
chmod 700 .ssh
并且修改sshd_config配置文件
AuthorizedKeysFile .ssh/authorized_keys
PubkeyAuthentication yes

  1. window端连接sftp
    sftp -b”C:\APP\getDDD.txt” -oStrictHostKeyChecking=no -oIdentityFile=”Identity” 用户名@服务器ip
    -b可执行的bat文件 -o访问的设置(StrictHostKeyChecking:如果设置成“yes”,ssh就不会自动把计算机的密匙加入“$HOME/.ssh/known_hosts”文件,并且一旦计算机的密匙发生了变化,就 拒绝连接。
    IdentityFile:自定义秘钥路径)

常见问题:
Permissions 0644 for ‘/root/.ssh/Identity’ are too open处理:
按照网上攻略是要更改id_rsa权限 但不管你设置什么权限,他都看做0644
这其实是你openssh的原因,你可以通过cygwin来下载openssh

你可能感兴趣的:(SFTP常见问题)