How can I login without password and run command in server at a local machine remotely?
Posted on In QALogin without PWD is fast and efficient. Running commands in server from local machine also have these benefits.
login without PWD: add PC A’s public key to PC B’s authorized keys.
> a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
> b@B's password:
Run command remotely
ssh root@MachineB "ls"
NOTE: running commands remotely is dangerous since there might be some ENVIRONMENT conflicts.
ssh-copy-id
can replace the manual way of the adding the public key to a remote account’s authorized_keys:
$ ssh-copy-id b@B
Sure, it works. Thank you for comments.