Skip to main content

Run command on remote server using ssh & RKE ssh config




Syntax:
  1.    ssh -i x.pem root@server "command"
  2.    ssh root@server "command"

Setup:
    1. login using private key:
       Generate ssh public and private key pairs using ssh-genkey .
   2. copy the public key to the destination server under a user.
       location of the content to be pasted 
       > vi .ssh/authorized_keys
   3. test the tunnelling from the source server .i.e ssh root@server 

RKE SSH Config:
  cluster.yml changes    

    ssh_agent_auth: true
 
Note: make sure the ssh_key_path is proper . If it's protected by passphrase then you need to run following commands to allow current terminal session to get access to key storage .
       > eval $(ssh-agent -s)
       > ssh-add   ( this will allow current agent to get access to the storage)
       > rke up
           
Miss configuration will lead to following error

Failed to set up SSH tunneling for host [35.237.xx.xx]: Can't retrieve Docker Info: error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info: Unable to access node with address [35.237.xx.xx:22] using SSH. Please check if you are able to SSH to the node using the specified SSH Private Key and if you have configured the correct SSH username. Error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [publickey none], no supported methods remain 




Comments