Windows CHMOD 600

前端 未结 12 1443
逝去的感伤
逝去的感伤 2020-12-24 11:11

I\'m trying to connect to Amazon EC2 using OpenSSH in windows but I need to set the permissions of my key file.

What is the windows equivalent of CHMOD 600

相关标签:
12条回答
  • 2020-12-24 11:31

    Right-click on the file/dir, select Properties then Security. Click Advanced, then Edit. Uncheck "Inheritable" and choose "Remove" in the dialog. Remove any explicit permissions left, add a "Full Access" permission to your username.

    0 讨论(0)
  • 2020-12-24 11:32

    I've go same issue. The solution, which worked was to set compatibility mode of ssh.exe to Windows XP SP3.

    -> This answer works for windows 7

    0 讨论(0)
  • 2020-12-24 11:33

    I prefer Cygwin over putty and you can just run chmod command in cygwin to change the permission of PEM key to be 400, then you are good to go.

    myuser@myuser-HP ~
    $ ssh -i /cygdrive/c/Users/myuser/Downloads/mykey.pem ec2-user@xx.xx.xx.xx
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0550 for '/cygdrive/c/Users/myuser/Downloads/mykey.pem' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    Load key "/cygdrive/c/Users/myuser/Downloads/mykey.pem": bad permissions
    Permission denied (publickey).
    
    myuser@myuser-HP ~
    $ chmod
    chmod: missing operand
    Try 'chmod --help' for more information.
    
    myuser@myuser-HP ~
    $ chmod 400 /cygdrive/c/Users/myuser/Downloads/mykey.pem
    
    myuser@myuser-HP ~
    $ ssh -i /cygdrive/c/Users/myuser/Downloads/meykey.pem ec2-user@xx.xx.xx.xx
    
           __|  __|_  )
           _|  (     /   Amazon Linux AMI
          ___|\___|___|
    
    https://aws.amazon.com/amazon-linux-ami/2015.09-release-notes/
    [ec2-user@ip-xxx ~]$ ohyeah I am in!
    
    0 讨论(0)
  • 2020-12-24 11:37

    chmod won't work in windows. Try the following method to restrict the access

    • Right click on the file > properties > security > advanced > disable inheritance > 'Convert inherited permissions into explicit permission on this object'
    • Click on "allow | everyone | Full Control" > edit > 'select a principal' > type your username > 'check names' > select your username > ok > ok > ok (ok until all windows are closed)
    0 讨论(0)
  • 2020-12-24 11:41

    Copy the file to Unix system throug scp and make chmod 600 to file. Then transfer file back to Windows machine. It worked for me.

    0 讨论(0)
  • 2020-12-24 11:42

    For unix & OSX

    Quite simply:

    chown -R $USER:users ~/.ssh/
    chmod -R 600 ~/.ssh/
    

    For Windows

    If the file is a windows (NTFS) symbolic link, the above won't work. You need to make it a regular file. I am not sure why.

    If you don't have openssh or cygwin, use chocolatey to install it easily using chocolatey.

    choco install cyg-get
    

    Open Cygwin Terminal that was installed with chocolatey and run (note that ssh-keygen creates new keys):

    cyg-get install openssh
    ssh-keygen
    cd ~/.ssh && explorer.exe .
    

    Verify keys are there (or replace them with the keys you want), and then in Cygwin shell:

    chown -R $USER:users ~/.ssh/
    chmod -R 600 ~/.ssh/
    

    Or for the rare case that you're using (and generated the keys from) chocolatey's SSH package:

    chown -R $USER:users  /cygdrive/c/Users/$USER/.ssh
    chmod -R 600 /cygdrive/c/Users/$USER/.ssh
    
    0 讨论(0)
提交回复
热议问题