shellGPT自动生成Linux命令

shellGPT自动生成Linux命令

一、shellGPT工具介绍

ShellGPT‌是一个由AI大型语言模型(LLM)驱动的命令行生产力工具,它允许用户通过终端与AI进行交互,执行各种任务和命令。

二、shellGPT安装

1、安装openssl 1.1.1版本

1.1 安装openssl 1.1.1

bash 复制代码
[root@localhost ~]# yum -y groupinstall "Development Tools"
[root@localhost ~]# yum -y install wget zlib-devel perl-core

[root@localhost ~]# wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz
[root@localhost ~]# tar xf openssl-1.1.1t.tar.gz 
[root@localhost ~]# cd openssl-1.1.1t/
[root@localhost ~]# ./configure --prefix=/usr/local/openssl --openssldir=/usr/local/openssl 
[root@localhost ~]# make -j $(nproc)
[root@localhost ~]# make install
bash 复制代码
[root@localhost ~]# vim /etc/profile
export PATH=$PATH:/usr/local/python3/bin:/usr/local/openssl/bin
export LD_LIBRARY_PATH=/usr/local/openssl/lib:$LD_LIBRARY_PATH

[root@localhost ~]# source /etc/profile
bash 复制代码
[root@localhost ~]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/openssl/lib

[root@localhost ~]# ldconfig

1.2 查看openssl版本

bash 复制代码
[root@localhost shell_gpt]# openssl version
OpenSSL 1.1.1t  7 Feb 2023

2、下载安装python3

bash 复制代码
[root@localhost shell_gpt]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
bash 复制代码
[root@localhost shell_gpt]#  tar xf Python-3.12.8.tar.xz 
[root@localhost shell_gpt]#  cd Python-3.12.8/
[root@localhost shell_gpt]#  ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
[root@localhost shell_gpt]#  make 
[root@localhost shell_gpt]#  make install
bash 复制代码
[root@localhost ~]# vim /etc/profile
export PATH=$PATH:/usr/local/python3/bin:/usr/local/openssl/bin

[root@localhost ~]# source /etc/profile
bash 复制代码
[root@localhost ~]# python3 --version
Python 3.12.8

3、修改pip国内仓库

bash 复制代码
[root@localhost ~]# cat /root/.pip/pip.conf 
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

4、安装shellGPT

bash 复制代码
[root@localhost ~]# pip3 install shell-gpt

5、修改shellGPT的配置文件

shell-gpt默认调用的是gpt,国内环境受限,修改其调用国内kimi api

在kimi api官方平台创建key, https://platform.moonshot.cn/console/account

bash 复制代码
[root@localhost shell_gpt]# pwd
/root/.config/shell_gpt

[root@localhost shell_gpt]# vim .sgptrc 
DEFAULT_MODEL=moonshot-v1-8k
OPENAI_API_KEY=sk-9uZmRscj56VyR5TTeOwofkU24iE3NjhUreC65OidQiCiUPM8
API_BASE_URL=https://api.moonshot.cn/v1

6、使用sgpt生成执行命令

bash 复制代码
[root@localhost shell_gpt]# sgpt -s "查看网卡ens33的mac地址"
ip link show ens33 | grep ether | awk '{print $2}'
[E]xecute, [D]escribe, [A]bort: e
00:0c:29:cc:6b:2f
相关推荐
斗转星移35 小时前
Ubuntu20.04 中使用vscode中编辑查看PlantUML
linux·vscode·uml·plantuml
正经教主6 小时前
【问题】解决docker的方式安装n8n,找不到docker.n8n.io/n8nio/n8n:latest镜像的问题
运维·docker·容器·n8n
sukida1006 小时前
BIOS主板(非UEFI)安装fedora42的方法
linux·windows·fedora
●^●6 小时前
Linux 权限修改详解:chmod 命令与权限数字的秘密
linux
唯独失去了从容6 小时前
WebRTC服务器Coturn服务器中的通信协议
运维·服务器·webrtc
光而不耀@lgy7 小时前
C++初登门槛
linux·开发语言·网络·c++·后端
joker_zsl7 小时前
docker的安装和简单使用(ubuntu环境)
运维·docker·容器
偶尔微微一笑8 小时前
AI网络渗透kali应用(gptshell)
linux·人工智能·python·自然语言处理·编辑器
Run1.8 小时前
深入解析 Linux 中动静态库的加载机制:从原理到实践
linux·运维·服务器
VI8664956I268 小时前
全链路自动化AIGC内容工厂:构建企业级智能内容生产系统
运维·自动化·aigc