Automated authentication between GIT and hosting

I'm planning to init GIT in one of the wp-content subfolders. Is there is a way to make the authentication between the WPMUDEV server and the Github repo work in an automated way (so that I don't need to manually authenticate on each push/pull) is to add an SSH key - or to get the current one?

  • Alex Stine
    • System Administrator

    Hello Gabor
    Hope you're doing well today!

    Could you please complete the following steps for adding your private SSH key for use with Git?
    1. Open a fresh SSH session.
    ssh -i key user@domain_or_ip
    2. In your home directory, use the below command to create a .ssh directory.
    mkdir -p .ssh
    3. Add your key.
    echo "private_key_goes_in_between_the_quotes" > id_rsa
    4. Now try your Git command again.

    Please let me know if we can assist you with this or any other questions.

    Thanks, Alex :smiley:

    • Gabor
      • WPMU DEV Initiate

      Also - are you sure that, when adding my key (supposing it doesn't throw the beforementioned error) I need to use the private key instead of the public key? I mean the private key is a multiline file, first 3 lines are:

      PuTTY-User-Key-File-2: ssh-ed25519
      Encryption: none
      Comment: ed25519-key-20190618

      Or is it only some specific part of the private key that needs to be used?

  • Gabor
    • WPMU DEV Initiate

    Hi Alex,

    Thanks for your reply. Unfortunately this method doesn't work.
    The command
    echo "private_key_goes_in_between_the_quotes" > id_rsa
    throws a "Forbidden syntax" error.

    Also I use Putty to SSH into the server, and the
    ssh -i key userdomain_or_ip
    login method doesn't work either, I tried two versions:
    ssh -i key userdomain
    ssh -i "key" userdomain
    But if I try to ssh with these commands, putty interprets it as the whole command is a username.

    Thoughts? :slight_smile:


  • Alex Stine
    • System Administrator

    Hello Gabor
    Hope you're well today and sorry for the late reply.

    To make this work properly, you will need to store your public SSH key in GitHub and use your private SSH key on the server. However, the key needs to be formatted as a standard "RSA" key and not a "PuTTY" key. I personally use Git Bash which has built in SSH support for Windows.

    Git Bash:
    RSA with PuTTY Key Generator:

    Once you generate a proper key and are able to login via SSH, you can instead use the vi command for adding the key.
    1. Login to SSH using Git Bash.
    ssh -i keyfile
    2. Switch to the .ssh directory.
    cd .ssh
    3. Use the vi command to start a new blank file.
    vi privkey
    4. Press "i" for insert mode.
    5. Use "CTRL+Shift+V" to paste the private key from your clipboard in to the terminal. Not all terminals have these shortcuts enabled by default.
    6. Press "ESC" to exit edit mode.
    7. Press ":wq" for command, write and quit.

    You can also add the key by adding a SFTP user from Hub Hosting SFTP/SSH tab. This user will allow you to authenticate to your site using a client that supports SFTP such as WinSCP or FileZilla.

    Here's some more information about SFTP and SSH with WPMU DEV Hosting.

    If you would like, I'd be happy to assist you in setting this up and then sending you the public key to add to your GitHub account.

    If you need further assistance with this, please don't hesitate to reach out to us with any questions you may have.

    Thanks, Alex :smiley:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.