阿里云免密登錄實操
# 生成公鑰
# 改成加一個 pem參數(shù)
ssh-keygen -t rsa -m PEM -P ''
xubin@xubindeMBP:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xubin/.ssh/id_rsa):
/Users/xubin/.ssh/id_rsa already exists.
Overwrite (y/n)? yes
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/xubin/.ssh/id_rsa.
Your public key has been saved in /Users/xubin/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:IeFPfrcQ3hhP64SRTAFzGIHl2ROcopl5HotRi2XNOGk xubin@xubindeMBP
The key's randomart image is:
+---[RSA 2048]----+
| .o*@=o |
| ..oEB=o |
| o@=+O . |
| B=+o @ . |
| =So* * |
| . o. = . |
| o |
| |
| |
+----[SHA256]-----+
# 查看公鑰
cat .ssh/id_rsa.pub
# 將公鑰拷貝到服務器
scp ~/.ssh/id_rsa.pub root@47.98.252.XXX:/root
# 將公鑰加入信任列表(服務器操作)
cat id_dsa.pub >> ~/.ssh/authorized_keys
deploy插件坑
1. 報錯提示如下:解釋私鑰不能parse。
Copy Files Over SSH: Cannot parse privateKey: Unsupported key format
解決方案: 上面生產(chǎn)密鑰對的過程,要加參數(shù) --pem生成的密鑰對就可以了。
參考鏈接:https://github.com/microsoft/azure-pipelines-tasks/issues/8818

image.png
2. 當右鍵deploy上傳的時候報如下錯誤
[Error] Could not deploy file '<file>': Error: Could not get relative path for <file>
解決方案:https://github.com/mkloubert/vs-deploy/issues/135
把項目單獨的作為vscode的單項目就可以了。否則會報這個錯誤。