您现在的位置是:网站首页 > 心得技巧 > 编程技巧编程技巧
【原】安装sshpass工具图文教程
不忘初心 2019-03-15 围观() 评论() 点赞() 【编程技巧】
简介:去官网下载:felixdeMacBook-Pro:Cellarfelix$./configure-bash:./configure:Nosuchfileordi
在几种快速上传文件到Linux服务器的方法一文中,提到了SCP方式上传,这种方式由于没有图形化界面,所以速度非常的快,但是有一个不爽的地方就是需要输入密码,简单的密码还好,如果是那种加密算法生成的很长一串的密码,那简直要人老命。
查了一下资料,可以利用sshpass工具来避免每次输入密码,而是直接将密码带着一起去执行命令,这样就方便很多了。
felixdeMacBook-Pro:5.1.34 felix$ sshpass -p test scp /Users/felix/workspace2/test/target/test.jar root@147.198.153.112:/usr/local/test
但是当我使用sshpass命令的时候,却报错“-bash: sshpass: command not found”,原来这个脚手架工具不是系统自带的,需要我们自己安装。
老规矩,去官网下载sshpass的二进制安装包
官网地址:http://sourceforge.net/projects/sshpass/files
下载完毕之后,解压目录如下:
有configure,直接./configure
felixdeMacBook-Pro:Cellar felix$ ./configure
-bash: ./configure: No such file or directory
felixdeMacBook-Pro:Cellar felix$ cd sshpass-1.06/
felixdeMacBook-Pro:sshpass-1.06 felix$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking for ANSI C header files... (cached) yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for unistd.h... (cached) yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for an ANSI C-conforming const... yes
checking for pid_t... yes
checking for ssize_t... yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking whether gcc needs -traditional... no
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking types of arguments for select... int,fd_set *,struct timeval *
checking return type of signal handlers... void
checking for select... yes
checking for posix_openpt... yes
checking for strdup... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
make
felixdeMacBook-Pro:sshpass-1.06 felix$ make
/Library/Developer/CommandLineTools/usr/bin/make all-am
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc -g -O2 -o sshpass main.o
make install
felixdeMacBook-Pro:sshpass-1.06 felix$ make install
./install-sh -c -d '/usr/local/bin'
/usr/bin/install -c sshpass '/usr/local/bin'
./install-sh -c -d '/usr/local/share/man/man1'
/usr/bin/install -c -m 644 sshpass.1 '/usr/local/share/man/man1'
文件上传了,但是报了一个错
felixdeMacBook-Pro:sshpass-1.06 felix$ sshpass -p test scp /Users/felix/workspace2/reader_v2/target/reader.jar root@147.198.153.112:/usr/local/test
/etc/profile.d/lang.sh: line 19: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
虽然报错了,但是还是可以上传。。。
原因:本机的$LC_CTYPE和服务器的$LC_CTYPE不一致
本地查看是UTF-8
felixdeMacBook-Pro:sshpass-1.06 felix$ echo $LC_CTYPE
服务器查看是空
[root@gitlab ~]# echo $LC_CTYPE
[root@gitlab ~]#
直接查看一下/etc/locale.conf文件
[root@gitlab ~]# cat /etc/locale.conf
LANG=en_US.utf8
[root@gitlab ~]#
只有LANG属性,需要我们手动给它配置一个LC_CTYPE属性
[root@st test]# cat /etc/locale.conf
LC_CTYPE=en_US.UTF-8
LANG=en_US.UTF-8
[root@st test]#
想让配置生效,还需要source一下
[root@gitlab ~]# source /etc/locale.conf
这里需要注意,虽然在本地电脑上echo的时候看到的是UTF-8,但是这里最好是和LANG的值保持一致,写成“en_US.UTF-8”,我分别在两台linux服务器上做过测试,其中一台写成UTF-8的时候source失败。
配置生效之后,我们再来echo查看一下
[root@st test]# echo $LC_CTYPE
en_US.UTF-8
[root@st test]#
此时,我们在客户端再次执行scp进行上传文件,就不会再有问题了
felixdeMacBook-Pro:5.1.34 felix$ sshpass -p test scp /Users/felix/workspace2/test/target/test.jar root@147.198.153.112:/usr/local/test
felixdeMacBook-Pro:5.1.34 felix$
不造为什么,实现了免密之后,上传进度百分比看不见了。。。
安装包网盘下载地址:sshpass-1.06二进制安装包免费下载
看完文章,有任何疑问,请加入群聊一起交流!!!
很赞哦! ()
相关文章
- sshpass-1.06二进制安装包免费下载
- IntelliJ IDEA 2024.2发布之后强推新UI,如何恢复老的经典UI界面
- Uninstall hasn't detected folder of intelli] lDEA installation. Probablyuninstall.exe was moved from the installation folder.
- 公众号CPS变现新宠:微赚淘客查券返利机器人,开启智能省钱赚钱新时代
- 高返利优惠券公众号推荐
- 返利公众号可信吗安全吗?返利机器人哪个佣金高?
- 唯品会购物返利公众号大揭秘:哪些真正好用的返利公众号?
- 饿了么优惠券免费领取:哪些公众号值得推荐?
- 哪些有用可靠的微信公众号能领淘宝优惠券?
- 微信返利最高的微信号推荐——让你的购物更加实惠!
标签云
猜你喜欢
- IntelliJ IDEA 2019.2已经可以利用补丁永久破解激活了
- IntelliJ IDEA 2019.3利用补丁永久破解激活教程
- IntelliJ IDEA高版本最灵活的永久破解激活方法(含插件激活,时长你说了算)
- Jetbrains全家桶基于ja-netfilter的最新破解激活详细图文教程
- IntelliJ IDEA 2022.1永久破解激活教程(亲测可用,持续更新)
- 分享几个正版 IntelliJ IDEA 激活码(破解码、注册码),亲测可用,持续更新
- ja-netfilter到底需不需要mymap,2021.3.2版本激活失效?
- 如何激活idea2022.1及以上版本中的插件(亲测可用)
- 【史上最全】IntelliJ IDEA最新2022.1版本安装和激活视频教学(含插件)
- IntelliJ IDEA 2022.2 版本最新2099年永久激活方法,亲测可用,也可以开启新UI了。
站点信息
- 网站程序:spring + freemarker
- 主题模板:《今夕何夕》
- 文章统计:篇文章
- 标签管理:标签云
- 微信公众号:扫描二维码,关注我们