ssh-2
This commit is contained in:
		
							parent
							
								
									873c000060
								
							
						
					
					
						commit
						bb1998ea21
					
				@ -10,18 +10,13 @@ jobs:
 | 
			
		||||
  ssh-test:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: 检查SSH密钥
 | 
			
		||||
        run: |
 | 
			
		||||
          if [ -z "${{ secrets.KEY }}" ]; then
 | 
			
		||||
            echo "SSH私钥未配置"
 | 
			
		||||
            exit 1
 | 
			
		||||
          fi
 | 
			
		||||
          echo "SSH私钥已配置"
 | 
			
		||||
 | 
			
		||||
      - name: 测试SSH连接
 | 
			
		||||
        run: |
 | 
			
		||||
          echo "${{ secrets.KEY }}" > ssh_key
 | 
			
		||||
          chmod 600 ssh_key
 | 
			
		||||
          ssh -o StrictHostKeyChecking=no \
 | 
			
		||||
              -i ssh_key \
 | 
			
		||||
              ${{ secrets.USER }}@${{ secrets.HOST }} "echo 'SSH连接成功!'"
 | 
			
		||||
      - name: SSH 连接测试
 | 
			
		||||
        uses: appleboy/ssh-action@master
 | 
			
		||||
        with:
 | 
			
		||||
          host: 120.27.198.238
 | 
			
		||||
          username: root
 | 
			
		||||
          password: Havocantelope420#
 | 
			
		||||
          port: '22'
 | 
			
		||||
          script: |
 | 
			
		||||
            echo "Running command on remote server"
 | 
			
		||||
            ls -lha
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user