ssh-keygen 一直回车会生成一个密钥,一般存放在.ssh文件下面
ssh-copy-id 用户名@服务器id
- 使用cmd可能会报错
- 使用Windows PowerShell也是报错
- 解决方法:找到本地的
Microsoft.PowerShell_profile.ps1文件,一般都是在用户/Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1把下面代码直接复制进去
function ssh-copy-id([string]$userAtMachine, $args){
$publicKey = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub"
if (!(Test-Path "$publicKey")){
Write-Error "ERROR: failed to open ID file '$publicKey': No such file"
}
else {
& cat "$publicKey" | ssh $args $userAtMachine "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1"
}
}
- 这段代码来源:
https://blog.csdn.net/Defiler_Lee/article/details/116278442然后再次尝试就没有问题了
-
如果上面的还是不行,可以使用
Microsoft Store上面的Ubuntu下载,然后就可以直接使用了 -
登录尝试可以直接登录
可以使用命令直接上传本地文件到服务器了
scp [options] [source] [user@]host:[destination]
[options]是可选的参数,例如-P port用于指定端口。[source]是本地文件的路径。[user@]host是远程Linux服务器的用户名和IP地址或主机名。[destination]是远程Linux服务器上的目标目录。
上传之前
上传
上传之后