From 807d1384b3b554f9b67c938316bfe41eb199a867 Mon Sep 17 00:00:00 2001 From: Kaiser-Yang <624626089@qq.com> Date: Fri, 7 Jun 2024 15:41:34 +0800 Subject: [PATCH 1/3] Add a script creating ssh-copy-id for Windows --- README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9af360b..5b7eff4 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ Let me show you an example creating a user named `kaiser` (note that you should 1. Let us first connect to the server. - Open your terminal (choose whatever the shell you like, in `Windows` it is `cmd` or `powershell`, and in `unix-like` system it is `bash`) + Open your terminal, and then choose whatever the shell you like, in `Windows` it is `cmd` or `powershell`. It is worth noting that `cmd` is not recommended, `powershell` is recommended, and if you have a `gitbash`, `gitbash` is strongly recommended. In `unix-like` system it is `bash`. Connect to your docker using this `ssh -p port root@address`, and the `port` and `address` are those the server manager have told you. Input your password (the password the manager have told you). Once it is correct, you will enter your docker (usually in `bash`). @@ -166,10 +166,24 @@ Let me show you an example creating a user named `kaiser` (note that you should If you don't have a ssh key, you may need create a new one. This command will help you: `ssh-keygen`. For simple way, you just need press enter key when it requires your confirm. If you already have one, just use the one you have created before. - Now you already have a ssh key, use this command to upload your ssh key to the docker for user `kaiser`: `ssh-copy-id -p port kaiser@address`, the `port` and the `address` are same with the before ones. Then you just need input the password of `kaiser`. + Now you already have a ssh key, use this command to upload your ssh key to the docker for user `kaiser`: `ssh-copy-id -p port kaiser@address`, the `port` and the `address` are same with the before ones. Then you just need input the password of `kaiser`. Note that in `Windows`, there is not a built-in `ssh-copy-id` command. But don't worry, I've found a script that defines a function called `ssh-copy-id`. Copy the code below into your `powershell` (`cmd` does not support this, if you are using `git bash`, `ssh-copy-id` is available). Then press enter key, after this, you can use `ssh-copy-id` in this shell. Then re-run the command `ssh-copy-id -p port kaiser@address`. If there is no any error, congratulations, you have done. But you have to do some more to make your login more convenient. + The script for creating a function called `ssh-copy-id` for `powershell`: + +```bash +function ssh-copy-id([string]$userAtMachine, $args){ + $publicKey = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub" + if (!(Test-Path "$publicKey")){ + Write-Error "ERROR: failed to open ID file '$publicKey': No such file" + } + else { + & cat "$publicKey" | ssh $args $userAtMachine "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1" + } +} +``` + 5. Let us do something more to make login with `ssh labserver` possible. Now you can use `ssh -p port kaiser@address` to login your docker without inputting any password. This is OK, but every time you must enter `-p port kaiser@address` this is inconvenient. From ea861493e04a86fcea59c3cbffdbe4661db76ad9 Mon Sep 17 00:00:00 2001 From: Kaiser-Yang <624626089@qq.com> Date: Wed, 10 Jul 2024 16:40:00 +0800 Subject: [PATCH 2/3] Add an MIT license --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bad3912 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 CMIPT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From dac6fc91a740239fa915155d8da17c951d94fd80 Mon Sep 17 00:00:00 2001 From: Kaiser-Yang <624626089@qq.com> Date: Wed, 31 Jul 2024 21:22:07 +0800 Subject: [PATCH 3/3] Bump up version to v0.1.4 --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5b7eff4..80a95da 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ [中文版本](README-zh.md) # Release Log +## Release-v0.1.4 +* Add a script creating ssh-copy-id for Windows +* Add an MIT license + ## Release-v0.1.3 * Fix typos * Add `sudo` before the `docker update --restart=always` command