使用证书安全快捷的连接SSH服务

经常使用ssh连接服务器的朋友,有时为了安全可能ssh还使用了非默认端口(22),这样每次使用密码登录时,都得按照如下的命令来连接服务器。这样显得有点不方便,因此推荐将密码设置复杂难以回溯,然后使用证书的形式来登录ssh服务器,免去了每次使用密码的麻烦。只要你把证书妥善保管,就会安全如初。 ssh user@hostname -p223 本地生成证书 首先使用ssh-keygen命令在本地生成证书,为了方便使用未设置证书密码。 $ ssh-keygen Generating public/private ed25519 key pair. Enter file in which to save the key (~/.ssh/id_ed25519): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in ~/.ssh/id_ed25519 Your public key has been saved in ~/.ssh/id_ed25519.pub The key fingerprint is: SHA256:Kcd0LM......Vams1XJA user@op36 The key's randomart image is: +--[ED25519 256]--+ | cef+.=.. | | ..oEo+.X | | aaaa+o O | | obbbb= B | |cccccc= S . | |dddd + . | |O w | | o | | | +----[SHA256]-----+ 设置SSH服务 使用scp或者其他方法将本地的public key文件~/.ssh/id_ed25519.pub上传至服务器。 ...

一月 9, 2025 · JQX

GitHub端口22连接超时改用443端口连接

clone github仓库时老是提示22端口超时,如下: $ git clone [email protected]:xtod/yuwang.git Cloning into 'yuwang'... ssh: connect to host github.com port 22: Connection timed out fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 还提示是否对该仓库具有访问权或者仓库是否存在,这不废话么,我肯定确认。 于是试着ssh -T了一下,看能不能访问,但提示的还是22端口超时 $ ssh -T [email protected] ssh: connect to host github.com port 22: Connection timed out 现在来看应该是访问问题,在此把访问端口改为443吧,不用22了,编辑~/.ssh/config写入如下内容: Host github.com HostName ssh.github.com User git Port 443 PreferredAuthentications publickey IdentityFile ~/.ssh/id_ed25519 然后再ssh -T试一下 ...

一月 1, 2025 · JQX

完全删除Docker

在使用了docker一段时间后,会发现系统上各种容器乱七八糟,启动的,未启动的,正常运行的,异常的,搞得人不胜其烦。 下面是一次完全删除docker容器并删除docker本身的实例,可以完美解决以上问题。 查询并停止/删除当前运行容器 ➜ ~ docker ps -aq 80bb62721c12 # 停止当前运行容器 ➜ ~ docker stop $(docker ps -aq) 80bb62721c12 # 删除当前运行容器 ➜ ~ docker rm $(docker ps -aq) 80bb62721c12 删除所有image镜像 ➜ ~ docker rmi $(docker images -q) Untagged: traffmonetizer/cli_v2:latest Untagged: traffmonetizer/cli_v2@sha256:4fc48893746664471a1c386efabb5eba0537955fe5ecae871ed4a5e5c33ecf03 Deleted: sha256:3f82fd6f8f4f5ae49cf715a45db4abb3c0bef25be4d351ebe82e747f8641dd0b Deleted: sha256:d732b5c154d947acd46254d7c729eea712f5dd3e0518884a50cc4ada4da9706d Deleted: sha256:037fbfa145577a9bc6472afdf57979ff128102d42806eebc4dcdbc7eb0c91ff5 Deleted: sha256:e44bc785a3f33dea2990cff187bc1c2b7fea4fa9dfa24a6c3ad3e4c149e7aa80 Deleted: sha256:aa0a4b16279d7f4e301aa29ff8bb3fb2e5eaf2417e8119bd3c92f99da975d674 Deleted: sha256:54d0ead5d2a5dd2e830b333508445bc7e9cbed60b1ec4091d667c71349a9b31c Deleted: sha256:bd00ba4d604e3a30bba51756da10622d2242a8540dc03a46a07584575d736590 Deleted: sha256:d4fc045c9e3a848011de66f34b81f052d4f2c15a17bb196d637e526349601820 卸载docker ➜ ~ apt purge docker-ce Reading package lists... Done Building dependency tree... Done Reading state information... Done The following package was automatically installed and is no longer required: pigz Use 'apt autoremove' to remove it. The following packages will be REMOVED: docker-ce* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 109 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 64321 files and directories currently installed.) Removing docker-ce (5:27.2.0-1~debian.12~bookworm) ... (Reading database ... 64312 files and directories currently installed.) Purging configuration files for docker-ce (5:27.2.0-1~debian.12~bookworm) ... ➜ ~ apt purge docker-ce-cli Reading package lists... Done Building dependency tree... Done Reading state information... Done The following package was automatically installed and is no longer required: pigz Use 'apt autoremove' to remove it. The following packages will be REMOVED: docker-ce-cli* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 40.9 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 64310 files and directories currently installed.) Removing docker-ce-cli (5:27.2.0-1~debian.12~bookworm) ... Processing triggers for man-db (2.11.2-2) ... ➜ ~ apt purge docker-ce-rootless-extras docker-buildx-plugin Reading package lists... Done Building dependency tree... Done Reading state information... Done The following packages were automatically installed and are no longer required: libslirp0 pigz slirp4netns Use 'apt autoremove' to remove them. The following packages will be REMOVED: docker-buildx-plugin* docker-ce-rootless-extras* 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. After this operation, 102 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 64111 files and directories currently installed.) Removing docker-buildx-plugin (0.16.2-1~debian.12~bookworm) ... Removing docker-ce-rootless-extras (5:27.2.0-1~debian.12~bookworm) ... ➜ ~ apt purge docker-compose-plugin Reading package lists... Done Building dependency tree... Done Reading state information... Done The following packages were automatically installed and are no longer required: libslirp0 pigz slirp4netns Use 'apt autoremove' to remove them. The following packages will be REMOVED: docker-compose-plugin* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 63.3 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 64102 files and directories currently installed.) Removing docker-compose-plugin (2.29.2-1~debian.12~bookworm) ...

八月 29, 2024 · JQX

树莓派最新版系统开启SSH登录和设置默认用户

下载系统为Raspberry Pi OS Lite,信息如下: Release date: May 3rd 2023 System: 32-bit Kernel version: 6.1 Debian version: 11 (bullseye) 下载后使用balenaEtcher写入tf卡。 进入到bootfs分区,新建ssh空文件即可开启默认ssh登录。 alair@op36 MINGW64 /f $ touch ssh 添加默认登录用户和密码 首先使用如下命令生成密码,password为自定义密码 alair@op36 MINGW64 /f $ echo 'password' | openssl passwd -6 -stdin $6$lAkAjoGFYOCieBlt$9ezLlyXlizpAP7lYNJRL.1cvdQOOkn.hsTnSQP3gtJT5EpfJvqwBo/BhdbUZ T.xMZIFyANfxf/8ckI590But20 然后还是在bootfs目录,新建userconf文件 vi userconf 写入以下内容 raspi:$6$lAkAjoGFYOCieBlt$9ezLlyXlizpAP7lYNJRL.1cvdQOOkn.hsTnSQP3gtJT5EpfJvqwBo/BhdbUZ T.xMZIFyANfxf/8ckI590But20 保存退出即可。 以上就会添加用户名为raspi密码为password的账户信息,接下来就可以使用ssh登录进行设置了。

六月 10, 2023 · JQX

使用gitolite自建立git server

服务器环境如下: ➜ ~ neofetch `.::///+:/-. --///+//-:`` pi@raspi2b `+oooooooooooo: `+oooooooooooo: ---------- /oooo++//ooooo: ooooo+//+ooooo. OS: Raspbian GNU/Linux 11 (bullseye) armv `+ooooooo:-:oo- +o+::/ooooooo: Host: Raspberry Pi 2 Model B Rev 1.1 `:oooooooo+`` `.oooooooo+- Kernel: 6.1.21-v7+ `:++ooo/. :+ooo+/.` Uptime: 1 hour, 53 mins ...` `.----.` ``.. Packages: 624 (dpkg) .::::-``:::::::::.`-:::-` Shell: zsh 5.8 -:::-` .:::::::-` `-:::- Terminal: /dev/pts/1 `::. `.--.` `` `.---.``.::` CPU: BCM2835 (4) @ 1.000GHz .::::::::` -::::::::` ` Memory: 70MiB / 921MiB .::` .:::::::::- `::::::::::``::. -:::` ::::::::::. ::::::::::.`:::- :::: -::::::::. `-:::::::: :::: -::- .-:::-.``....``.-::-. -::- .. `` .::::::::. `..`.. -:::-` -::::::::::` .:::::` :::::::` -::::::::::` :::::::. .::::::: -::::::::. :::::::: `-:::::` ..--.` ::::::. `...` `...--..` `...` .:::::::::: `.-::::-` 服务器添加git用户并设置密码 ...

六月 9, 2023 · JQX