您的位置:首页 > 其它

安装ssh登陆其它机器

2015-09-25 17:10 176 查看
最近做分布式抓取,需要在其它机器上安装一些软件,并运行爬虫程序。

这个时候通过ssh就很方便了

1. 在每个机器上安装openssh-server, openssh-client

命令sudo apt-get install openssh-server openssh-client

2. 在一个机子上访问其它机器 (访问局域网)

命令 ssh 192.168.8.151就进去了其它机器

3. 公司的机器一般名字都相同,这时我们想区分每台机器,就用http://askubuntu.com/questions/145618/how-can-i-shorten-my-command-line-bash-prompt提到的方法来更改bash prompt

3.1)如果只需要在当前terminal更改,使用命令PS1='\u@daidai-151:\W\$
',那么命令行名称就变成了moma@daidai-151,其中moma是用户名

3.2)如果需要永久更改,

命令sudo vi ~/.bashrc

打开.bashrc文件后,找到

if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi


改成如下

if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@daidai-151\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@daidai-151:\W\$ '
fi

4. 简单的拷文件的方法,要把本机/home/moma/Desktop中的a.txt文件拷到机器a, b, c, d, e等中,那么我们

4.1)在本机/home/moma/Desktop下打开一个terminal,然后运行python -m SimpleHTTPServer 8888

4.2)在机器a中某个位置,输入命令wget http://192.168.8.151/a.txt 就能把151这个机子上的a.txt拷贝过来
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: