上QQ阅读APP看书,第一时间看更新
SSHing before running a command
While you'll mostly use SSH for connecting to remote boxes, it's also possible to run a command on a remote host without having to linger there.
Here, we're running a command to print the hostname file on the remote box, while staying on centos1:
[vagrant@centos1 ~]$ ssh 192.168.33.11 "cat /etc/hostname"
Enter passphrase for key '/home/vagrant/.ssh/id_rsa':
centos2
[vagrant@centos1 ~]$
This is especially useful for automation software, or scripts that you want to run locally but which interact with remote machines.