...
 
Commits (2)
    https://gitcode.net/quintin/ssh-manager/-/commit/25e5b9042d085ab4bf79f4485ba654e604d9fea7 删除无效代码 2022-11-02T14:02:20+08:00 quintin 2449164582@qq.com https://gitcode.net/quintin/ssh-manager/-/commit/4ab90d32f7feeb0beee1dcc42ae9eae58081b225 添加 README 2022-11-02T14:18:53+08:00 quintin 2449164582@qq.com
# ssh-manager
基于 expect 工具实现 ssh 自动登陆服务器, 管理服务器 ssh 连接
## 1. ArchLinux/Manjaro 发行版打包
```shell
git clone https://github.com/quintin-lee/ssh-manager.git
cd ssh-manager
makepkg
```
## 2. 安装
``` shell
sudo pacman -U 包名
在 PATH 中加入 /usr/local/ssh-manager
```
## 3. 使用
### 3.1 配置
在 /usr/local/ssh-manager/host.conf 文件中添加 ssh 连接信息, 如下:
```shell
# server host/ip user possword port
localhost 127.0.0.1 root 123456 22
```
### 3.2 连接
运行 ssh-connect, 选择要练的服务器即可自动连接到服务器
```shell
$ ssh-connect
1) localhost
Enter a number[1-1]:1
spawn ssh root@192.168.28.93 -p 22
The authenticity of host '192.168.28.93 (192.168.28.93)' can't be established.
ED25519 key fingerprint is SHA256:g56ErKDN0Ypa1o3kx7DVFb3l2uDcPMJQQAN8muLeocE.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.28.93' (ED25519) to the list of known hosts.
root@192.168.28.93's password:
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Wed Oct 26 03:28:24 2022 from 192.168.4.182
[root@bogon ~]# export TERM=xterm
[root@bogon ~]#
```
...@@ -29,7 +29,7 @@ PS3="Enter a number[1-${#servers[*]}]:" ...@@ -29,7 +29,7 @@ PS3="Enter a number[1-${#servers[*]}]:"
select server in ${servers[@]} select server in ${servers[@]}
do do
# $REPLY 输入的标号 # $REPLY 输入的标号
#echo $REPLY # convert tab to space
str=$(echo ${ALL_SERVERS[${REPLY}]} | sed 's#\t# #g'); str=$(echo ${ALL_SERVERS[${REPLY}]} | sed 's#\t# #g');
info=(${str}) info=(${str})
if [ "x${server}" != "x" ] if [ "x${server}" != "x" ]
...@@ -38,10 +38,6 @@ do ...@@ -38,10 +38,6 @@ do
user_name=${info[2]} user_name=${info[2]}
user_passwd=${info[3]} user_passwd=${info[3]}
port=${info[4]} port=${info[4]}
#host=$(grep "${server}" ${CONF} | awk '{print $2}')
#user_name=$(grep "${server}" ${CONF} | awk '{print $3}')
#user_passwd=$(grep "${server}" ${CONF} | awk '{print $4}')
#port=$(grep "${server}" ${CONF} | awk '{print $5}')
${CMD_DIR}/login.exp ${host} ${user_name} ${user_passwd} ${port} ${CMD_DIR}/login.exp ${host} ${user_name} ${user_passwd} ${port}
break; break;
fi fi
......