Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use with npm script? #14

Closed
SvenBudak opened this issue Jul 22, 2019 · 16 comments
Closed

How to use with npm script? #14

SvenBudak opened this issue Jul 22, 2019 · 16 comments

Comments

@SvenBudak
Copy link

I cant find in the documentation any about how to load / use the config file with npm script?

I install it with npm install ssh-deploy-release --save then i add npm run ssh-deploy-release? but how i tell him what configs he have to use?

@nstCactus
Copy link
Member

You'd be better off using deployator for this use case. This is a command-line interface for ssh-deploy-release.

@SvenBudak
Copy link
Author

Oh wow thank you for this fast reply! One last question about this... i use MacOS and try to use the script. but he tell me Cannot parse privateKey: Unsupported key format i use id_ed25519. but at last i dont want to add privateKeyFile and passphrase to the config, because security reasons. Why it not just using the internal key chain like all my other tools? can i set up this anywhere?

@nstCactus
Copy link
Member

You can provide the path to the ssh-agent socket using the agent property. It's not documented directly in ssh-deploy-release because it's an ssh2 option and the ssh-deploy-release options object is passed to ssh2 : https://www.npmjs.com/package/ssh-deploy-release#options

Example:

module.exports = function (options) {
  return {
    common: {
      currentReleaseLink: 'current',
      mode:     'synchronize',
      rsyncOptions : '--exclude-from="rsync_excludes.txt" --delete-excluded'
    },

    // Environment specific configuration
    environments: {
      api_preprod: {
        host: 'example.com',
        username: 'root',
        agent: process.env.SSH_AUTH_SOCK,
        localPath:  'dist',
        deployPath: '/srv/htdocs/example.com/www',
      },
    },
  };
};

@SvenBudak
Copy link
Author

SvenBudak commented Jul 22, 2019

I think it would be very great if someone can add this information to the documentation :)

But with agent: process.env.SSH_AUTH_SOCK, i get now following error: Fatal error : Error: All configured authentication methods failed

my whole config look like: (I have on my side ofc real path and username in the review config ;) But i removed password, because i want to use only SSH.

module.exports = function (options) {

    // @see https://www.npmjs.com/package/ssh-deploy-release

    return {

        // Common configuration
        // These options will be merged with those specific to the environment
        common: {
            localPath: 'dist',
            share: {},
            exclude: [],
            create: []
        },


        // Environment specific configuration
        environments: {

            review: {
                host: 'my.server.com',
                username: 'username',
                agent: process.env.SSH_AUTH_SOCK,
                deployPath: '/path/to',
                allowRemove: true,
            },

            preProduction: {
                host: 'my.server.com',
                username: 'username',
                password: 'password',
                deployPath: '/path/to',
            },

            production: {
                host: 'my.server.com',
                username: 'username',
                password: 'password',
                deployPath: '/path/to',
            }

        }
    }
};

By the way: I am talking about a solution that read keyfiles automaticly, if on Windows is PuTTys Peagend loaded or if on mac and linux systems are keys added to keychain with ssh add -key

@nstCactus
Copy link
Member

We're reaching the edge of my ssh-agent knowledge. Have you checked that your ssh-agent knows about your key? You can do this with the following command ssh-add -L

@SvenBudak
Copy link
Author

No problem, my knowledge about ssh-agent is about on 5% ;P

ssh-add -L shows me my key yes.

@nstCactus
Copy link
Member

Sorry I cannot help you much more.

I made a quick test & was able to deploy to my server using only the agent property (with no password nor privateKeyFile properties). But it's pretty much the same config as the one you posted.

I got the Fatal error : Error: All configured authentication methods failed when trying again without any of the agent, password nor privateKeyFile properties.

@SvenBudak
Copy link
Author

maybe because my keyformat... what format you use? and what keyformats are supported? when i use direct path to key he say that the keyformat is not supported (ed25519)

@nstCactus
Copy link
Member

nstCactus commented Jul 22, 2019

Could be. I found this ssh2 issue which suggests you need node 12 and ssh2 >= 0.8.3 to get ed25519 key format support.

The next release of ssh-deploy-release will use the latest ssh2 version, but it's still being tested.

@SvenBudak
Copy link
Author

SvenBudak commented Jul 22, 2019

Hmmm i have only OpenSSH_7.9p1 and LibreSSL 2.7.3 and i can only use LTS version of NodeJS... Then i maybe really are forced to use classic way to deploy... but thanks very much for your help and time!

@SvenBudak
Copy link
Author

@nstCactus is with ssh2 this package meand? https://www.npmjs.com/package/ssh2#client
i just need to install it globally? or i should install it and add it to devDependencies?
and i need to use it somehow in the npm script?

@nstCactus
Copy link
Member

Yes this is the package I was talking about but it won't help you. It's an ssh-deploy-release dependency and I don't think you can force it to use a specific version.
That being said, we are currently testing a new version of ssh-deploy-release that uses the latest ssh2 version, so a new version might be released in a few days.
Please note that without node 12, it probably won't change anything to your key format issue.

@SvenBudak
Copy link
Author

i updated to nodeJS 12. then i will wait for updated on the deployator package :)

@nstCactus
Copy link
Member

Today I published beta versions of ssh-deploy-release & deployator with support for the ed25519 key format (as long as you run node 12).

They haven't been heavily tested but if you want to give it a try, you can them using this command : npm i deployator@beta (keep a backup of your data just in case…).

Any feedback will be greatly appreciated!

@SvenBudak
Copy link
Author

Thanks! but i figured out that i need to wait that NodeJS 12 gets stable. i have no admin rights to install this on my companys computer and also other people here have only LTS installed =(

@nstCactus
Copy link
Member

All right. Closing it for now but feel free to reopen if you run into issues once you are able to upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants