ssh - Bitbuket 管道 - 如何设置 ssh
问题描述
当我的管道运行时,我收到以下错误:
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/config
debug1: key_load_private_type: incorrect passphrase supplied to decrypt private key
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
lost connection
这是我的 .yml 文件:
image: maven:3.3.9
pipelines:
default:
- step:
caches:
- maven
name: Build
script: # Modify the commands below to build your repository.
- echo "Build Start"
- mvn package
- echo $BUILD_DIR
- mv target/**.jar target/transpoDirect.jar
artifacts:
- target/**.jar
- step:
name: Deploy
image: maven:3.3.9
script:
- ls -la .
- scp -i ~/.ssh/config -P 7822 -v -o StrictHostKeyChecking=no target/*.jar root@$hostName:/var/transpoDirect/.
- ssh -p 7822 -i ~/.ssh/config -v -o StrictHostKeyChecking=no root@$hostName sudo service transpoDirect restart
我试过的是 chmod ~/.ssh 文件夹和文件到 777
hostName 变量在存储库的设置中设置。
重新生成密钥。粘贴在远程服务器的 authorize_keys 文件中,但我仍然收到相同的错误
授权密钥的位置:
==================================================== ===============
这是有效的:
- 从 bitbucket 的管道中删除了 SSH 密钥。
- 使用以下命令在远程服务器上生成 SSH 密钥:ssh-keygen
- 上述命令使用默认值,不设置密码。
- 生成密钥的默认位置是:/root/.ssh
- .ssh 文件夹被隐藏。使用 winSCP 您可以取消隐藏隐藏文件夹。
- 从远程服务器复制 id_rsa.pub 的内容并粘贴到 bitbucket 的 SSH 中。
- 使用 /root/.ssh 中的 id_rsa.pub 的内容创建了 authorized_keys
- 从远程服务器复制 id_rsa 的内容并粘贴到 bitbucket 的 SSH 中。
这会将 jar 复制到远程服务器:
- scp -i /root/.ssh -4 -P 7822 -v -o StrictHostKeyChecking=no target/*.jar root@$hostName:/var/transpoDirect/。
这将重新启动服务,如下所述:https ://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html
- ssh -4 -p 7822 -i /root/.ssh -v -o StrictHostKeyChecking=no root@$hostName sudo service transpoDirect restart
解决方案
这是有效的:
- 从 bitbucket 的管道中删除了 SSH 密钥。
- 使用以下命令在远程服务器上生成 SSH 密钥:ssh-keygen
- 上述命令使用默认值,不设置密码。
- 生成密钥的默认位置是:/root/.ssh
- .ssh 文件夹被隐藏。使用 winSCP 您可以取消隐藏隐藏文件夹。
- 从远程服务器复制 id_rsa.pub 的内容并粘贴到 bitbucket 的 SSH 中。
- 使用 /root/.ssh 中的 id_rsa.pub 的内容创建了 authorized_keys
- 从远程服务器复制 id_rsa 的内容并粘贴到 bitbucket 的 SSH 中。
这会将 jar 复制到远程服务器:
scp -i /root/.ssh -4 -P 7822 -v -o StrictHostKeyChecking=no target/*.jar root@$hostName:/var/transpoDirect/。
这将重新启动服务,如下所述:https ://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html
ssh -4 -p 7822 -i /root/.ssh -v -o StrictHostKeyChecking=no root@$hostName sudo service transpoDirect restart
进一步说明:该文件应放在 $HOME/.ssh/authorized_keys 您可以通过 eval echo "$HOME" 检查 $HOME 的位置 另外,要了解的是 id_rsa 是私有文件 - 这意味着该文件是不共享,但 id_rsa.pub 是公共文件,这是要提供给其他服务器的文件。
推荐阅读
- .net - c#在扫描的文档图像中逐行滚动文本
- databricks - 在 Databricks 文件系统中更改文件夹名称
- python - 基于灰度在图像Python上查找特定点
- c - 宏扩展插入一个额外的逗号和括号?
- java - 无法接受在父窗口中弹出警报并且子窗口仍然出现在屏幕中
- ios - 如何在 UITableView 多选期间更改默认轮的颜色?
- ssl-certificate - 我们如何验证是否将正确的证书导入到 trust.jks
- sql - 在 SQL 中显示重复值时显示其他值列
- python - InvalidArgumentError:无法挤压 dim[1],预期维度为 1,得到 16
- python - 如何为有条件的每一行生成一个随机数?