LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 923|回复: 11

scp的时候按tab,可以自动补齐服务器上的目录名

[复制链接]
发表于 2005-8-17 14:49:51 | 显示全部楼层 |阅读模式
前提是设置好了公钥登录
并且执行了ssh-add

然后scp somefile username@server:/
这个时候按tab,就会出现
服务器上根目录下的所有文件夹
发表于 2005-8-17 15:18:54 | 显示全部楼层
看清楚了,那个不是服务器的,是你自己的文件夹!!!
回复 支持 反对

使用道具 举报

发表于 2005-8-17 15:26:43 | 显示全部楼层
是你自己目录下和服务器上的目录刚好一样吧。而且这个tab补齐是bash实现的,跟ssh有啥关系?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-17 17:11:14 | 显示全部楼层
Post by supernatural
看清楚了,那个不是服务器的,是你自己的文件夹!!!

我用ethereal抓过包的
我在没有任何ssh登录的情况下
打了上面一串,然后按tab
ethereal给我抓到了一堆ssh的包
我不按的话,就抓不到任何包

我打的是user@server:/home
它给我显示的是服务器上所有用户的名字
有十来个
我的机器只有3个用户

你怎么解释这个现象

PS:
我的系统Gentoo
openssh版本4.1_p1
bash版本3.0
bash-completion版本20050721
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-17 17:34:53 | 显示全部楼层
check it out
http://www.caliban.org/bash/#completion
think twice next time before you type 3 exclamation !!!
回复 支持 反对

使用道具 举报

发表于 2005-8-17 20:35:40 | 显示全部楼层
Post by zhllg
check it out
http://www.caliban.org/bash/#completion
think twice next time before you type 3 exclamation !!!


是这句么?

If you're a sysadmin type, you'll find ssh completion particularly useful, since this completes hostnames based on the contents of your known_hosts files. Also, if you NFS mount a lot of hosts, try mount hostname:<Tab>.

没说可以补齐服务器上的文件名阿。


1. 设置好了公钥登录
2. 执行了ssh-add
(bash3.0 & openssh 4.1p1)
但还是不行。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-18 00:50:34 | 显示全部楼层
不,我贴那个的意思是让你装bash-completion

你可以google "bash scp completion"
回复 支持 反对

使用道具 举报

发表于 2005-8-18 14:24:53 | 显示全部楼层
Post by zhllg
不,我贴那个的意思是让你装bash-completion

你可以google "bash scp completion"


搞定,谢谢了。看来是由于我的/etc/bash.bashrc里(debian/sid),关于bash_complete的部分被注释掉了:-P
回复 支持 反对

使用道具 举报

发表于 2005-8-18 22:49:53 | 显示全部楼层
Excellent !

1. download bash_completion
http://www.caliban.org/files/bash/bash-completion-20050721.tar.gz

2. unpack it to temporary dir
# tar xfz bash-completion-20050721.tar.gz -C /tmp
# cp /tmp/bash_completion/bash_completion /etc

3. add the following line into /etc/bashrc

if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

4. re-open a terminal or logout the login, u will see it works

Thanks very much.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-19 02:31:48 | 显示全部楼层
you are welcome
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表