欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jenkins通過(guò)sshPut傳輸文件時(shí)報(bào)錯(cuò)Permission?denied的SftpException的問(wèn)題及解決方案

 更新時(shí)間:2023年08月02日 10:20:09   作者:天草二十六_簡(jiǎn)村人  
使用jenkins的ssh插件傳輸文件至遠(yuǎn)程機(jī)器的指定目錄,php程序打包后,經(jīng)過(guò)zip壓縮為oms.zip,這篇文章主要介紹了jenkins通過(guò)sshPut傳輸文件的時(shí)候,報(bào)錯(cuò)Permission?denied的SftpException,需要的朋友可以參考下

一、背景

使用jenkins的ssh插件傳輸文件至遠(yuǎn)程機(jī)器的指定目錄,php程序打包后,經(jīng)過(guò)zip壓縮為oms.zip

zip -rq oms.zip ./ -x '.git/*' -x .env

然后我們求md5值

md5sum oms.zip

最后執(zhí)行傳輸。

09:03:02  Executing command on ssh[116.61.10.149]: mkdir -p /opt/php/oms sudo: false
[Pipeline] sshPut
[Pipeline] }
09:03:07  Sending a file/directory to ssh[116.61.10.149]: from: /home/jenkins/agent/workspace/PROD_resource_php_oms/oms.zip into: /opt/php/oms
09:03:08  Failed SFTP PUT: /home/jenkins/agent/workspace/PROD_resource_php_oms/oms.zip -> ssh:/opt/php/oms

二、報(bào)錯(cuò)詳情

Caused: org.hidetake.groovy.ssh.operation.SftpException: Failed SFTP PUT: /home/jenkins/agent/workspace/PROD_resource_php_oms/oms.zip -> ssh:/opt/php/oms: (SSH_FX_PERMISSION_DENIED: The user does not have sufficient permissions to perform the operation): Permission denied

三、ssh pipeline

    def remote = [:]
    remote.name = 'ssh'
    remote.host = '116.61.10.149'
    remote.port = 22
    remote.allowAnyHosts = true
    def credentialsId = "285a0928-f35f-4485-a54f-48321aea7212"
withCredentials([sshUserPrivateKey(credentialsId: credentialsId, keyFileVariable: 'identity', passphraseVariable: '')]) {
        remote.user = 'phpuser'
        remote.identityFile = identity
        // 創(chuàng)建遠(yuǎn)程目錄
        sshCommand remote: remote, command: "mkdir -p " + remoteFilePath
       // 上傳jar或者zip包,以及md5文件
        sshPut remote: remote, from: jarFileName, into: remoteFilePath
        sshPut remote: remote, from: md5FileName, into: remoteFilePath
        // 如果是zip壓縮文件,額外上傳一個(gè).version文件,內(nèi)容是版本號(hào)
        if (".zip" == fileType) {
            sshPut remote: remote, from: ".version", into: remoteFilePath
        }
    }

四、排查過(guò)程

手動(dòng)登錄遠(yuǎn)程機(jī)器116.61.10.149,然后進(jìn)入目標(biāo)目錄,查看目錄所屬的用戶是root,而非phpuser,所以報(bào)沒(méi)有權(quán)限的錯(cuò)誤。

[root@TEST-jekines ~]# ssh phpuser@116.61.10.149
Last login: Thu Jul 28 09:52:44 2022 from 116.61.10.149
Welcome to Alibaba Cloud Elastic Compute Service !
[phpuser@awx-pre ~]$ cd /opt/php
[phpuser@awx-pre php]$ ll
total 15
drwxr-xr-x 2 root root 4096 Jul 25 09:51 oms

查看文件夾的詳情

[phpuser@awx-pre php]$ stat oms
  File: ‘oms'
  Size: 4096            Blocks: 1          IO Block: 16384  directory
Device: 56h/86d Inode: 6993897     Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-07-25 09:51:29.613946996 +0800
Modify: 2023-07-25 09:51:29.613946996 +0800
Change: 2023-07-25 09:51:29.613946996 +0800
 Birth: -

文件夾oms是在2023-07-25 09:51:29由用戶root創(chuàng)建的,所以當(dāng)phpuser用戶來(lái)嘗試創(chuàng)建目錄的時(shí)候,會(huì)失敗,繼而傳輸文件也報(bào)權(quán)限非法的錯(cuò)誤。

五、解決問(wèn)題

rm -rf /opt/php
  • 刪除后,目錄/opt/php下為空
  • 重試上傳文件
[phpuser@awx-pre oms]$ ll -h
total 170M
-rw-rw-r-- 1 phpuser phpuser 170M Jul 31 10:06 oms.zip
-rw-rw-r-- 1 phpuser phpuser   33 Jul 31 10:06 oms.zip.md5

到此這篇關(guān)于jenkins通過(guò)sshPut傳輸文件的時(shí)候,報(bào)錯(cuò)Permission denied的SftpException的文章就介紹到這了,更多相關(guān)jenkins通過(guò)sshPut傳輸文件報(bào)錯(cuò)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • WebStorm最近免安裝參數(shù)免激活碼 真永久激活方法

    WebStorm最近免安裝參數(shù)免激活碼 真永久激活方法

    相信很朋友因?yàn)閃ebStorm最新激活碼或激活補(bǔ)丁的安裝參數(shù)每月都會(huì)失效而煩惱,下面小編給大家分享一個(gè)一勞永逸的永久激活的方法
    2020-12-12
  • Prometheus和NodeExporter安裝監(jiān)控?cái)?shù)據(jù)說(shuō)明

    Prometheus和NodeExporter安裝監(jiān)控?cái)?shù)據(jù)說(shuō)明

    這篇文章主要為大家介紹了Prometheus和node?exporter安裝監(jiān)控?cái)?shù)據(jù)說(shuō)明,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • ChatGPT與Remix?Api服務(wù)在瀏覽器url地址中對(duì)話詳解

    ChatGPT與Remix?Api服務(wù)在瀏覽器url地址中對(duì)話詳解

    這篇文章主要為大家介紹了ChatGPT與Remix?Api服務(wù)在瀏覽器url地址中對(duì)話詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-05-05
  • vscode中使用Autoprefixer3.0無(wú)效的解決方法

    vscode中使用Autoprefixer3.0無(wú)效的解決方法

    這篇文章主要介紹了vscode中使用Autoprefixer3.0無(wú)效的解決方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-06-06
  • 趁熱打鐵!HTTPGet與HTTPPost的區(qū)別詳解

    趁熱打鐵!HTTPGet與HTTPPost的區(qū)別詳解

    這篇文章主要介紹了趁熱打鐵!HTTPGet與HTTPPost的區(qū)別詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-10-10
  • Web Jmeter–接口測(cè)試工具詳解

    Web Jmeter–接口測(cè)試工具詳解

    本文主要介紹Web Jmeter接口測(cè)試工具,這里整理了詳細(xì)的資料來(lái)說(shuō)明Jmeter 的使用,有需要的小伙伴可以參考下
    2016-09-09
  • WebStorm?發(fā)布2021.3重大更新新功能介紹

    WebStorm?發(fā)布2021.3重大更新新功能介紹

    ?2021年度最后一次重大更新WebStorm?2021.3來(lái)了!此更新充滿了期待已久的增強(qiáng)功能,包括對(duì)遠(yuǎn)程開發(fā)的支持、改進(jìn)的?HTML?完成、重新設(shè)計(jì)的?Deno?集成等
    2021-12-12
  • 看完工資立馬翻3倍!(非程序員勿看)

    看完工資立馬翻3倍?。ǚ浅绦騿T勿看)

    負(fù)責(zé)粘貼你也可以做到!
    2019-02-02
  • 一文教你在現(xiàn)有Vue項(xiàng)目中嵌入Blazor項(xiàng)目

    一文教你在現(xiàn)有Vue項(xiàng)目中嵌入Blazor項(xiàng)目

    目前官方只提供了angular和react倆種示例,所以本教程將來(lái)講解如何在Vue的現(xiàn)有項(xiàng)目中嵌入使用Blazor項(xiàng)目。文中的方法講解詳細(xì),感興趣的小伙伴可以了解一下
    2023-01-01
  • matlab畫三維圖像的示例代碼(附demo)

    matlab畫三維圖像的示例代碼(附demo)

    這篇文章主要介紹了matlab畫三維圖像的示例代碼(附demo),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12

最新評(píng)論