Thermal_zone2 is the CPU package temp for me. You’ll need to enter the username & IP address for your Proxmox most. $ cp /root/.ssh/id_rsa /configįrom here, it’s just the config in HA. Once again, using the Terminal & SSH add-on in HA. I found that the sensor in HA couldn’t get to the default /root/.ssh/ directory so I copied the id_rsa file to the HA config directory. I tested this by running the following command in the Terminal & SSH add-on in HA. To push the public key to the Proxmox server: $ ssh-copy-id should now be able to SSH to the Proxmox host without needing to enter a password. To generate the SSH key on the HA VM (I used the Terminal & SSH add-on). Essentially you’ll want to run the following commands: Most of the info below is from this awesome community but I thought it would help to have it in once placeĭigital Ocean has a great guide for creating a pair of SSH keys. Print("No IP addresses were given to run script.I run HA in a VM on a Proxmox host and since migrating from a Pi 3B+, I’ve wanted to keep an eye on the host’s CPU temp. Print("Key added: ", ip) # prints if successful Os.system('sshpass -p ' + passwd + ' ' + cmd) | pssh -h <(printf "%s\n" srv0'.format(ip,args.port,passwd) You can of course also use printf to generate dynamic content too: $ cat. The above could be used to extract a list of IPs from my ~/.ssh/config file. I've expanded the above so it's easier to read here, but I generally run it all on a single line like so: $ cat ~/.ssh/my_id_rsa.pub | pssh -h ips.txt -l remoteuser -A -I -i 'umask 077 mkdir -p ~/.ssh afile=~/.ssh/authorized_keys cat - > $afile sort -u $afile -o $afile'īy using pssh you can forgo having to construct files and either provide dynamic content using -h <(.some command.) or you can create a list of IPs using another of pssh's switches, -H "ip1 ip2 ip3".įor example: $ cat. That's important, since we don't want $afile to get evaluated until after it's executing on the remote server. Notice the single ticks!Īlso pay special attention to the fact that all these commands are nested inside of single quotes. This will eliminate your pubkey from getting appended multiple times. NOTE: That last bit is to handle the case where you run the above multiple times against the same servers. sort -u $afile -o $afile - uniquely sorts authorized_keys file and saves it.ssh directory as a file name authorizedkeys. cat - > $afile - take input from STDIN and append to authorized_keys file Step 2: Upload SSH Key to 192.168.0.11 Use SSH from server 192.168.0.12 and upload a new generated public key ( idrsa.pub) on server 192.168.0.11 under sheena ‘s.set a variable, $afile, with the path to authorized_keys file. ![]() rw- 1 remoteuser remoteuser 771 May 21 23:03 /home/remoteuser/.ssh/authorized_keysĬreate the directory ~/.ssh and ignore warning us if it's already there Set the remote user's umask to 077, this is so that any directories or files we're going to create, will have their permissions set accordingly like so: $ ls -ld ~/.ssh ~/.ssh/authorized_keysĭrwx- 2 remoteuser remoteuser 4096 May 21 22:58 /home/remoteuser/.ssh These are the commands that pssh will run on each server: ' \ '.cmds to add pubkey.' - this is the trickiest part of what's going on, so I'll break this down by itself (see below).-i tells pssh to send any output to STDOUT rather than store it in files (its default behavior).-A tells pssh to ask for your password and then reuse it for all the servers that it connects to.-l is the remote server's account (we're assuming you have the same username across the servers in the IP file).pssh uses the -I switch to ingest data via STDIN.cat outputs the public key file to pssh.The above script is generally structured like so: $ cat | pssh -h -l -A -I -i '.cmds to add pubkey.' Warning: do not enter your password if anyone else has superuser | pssh -h ips.txt -l remoteuser -A -I -i \ Here's an example that does the job: $ cat ~/.ssh/my_id_rsa.pub \ NOTE: Using this method doesn't allow you to use ssh-copy-id, however, so you'll need to roll your own method for appending your SSH pub key file to your remote account's ~/.ssh/authorized_keys file. Rather than type your password multiple times you can make use of pssh and its -A switch to prompt for it once, and then feed the password to all the servers in a list. I created a ssh key and then I need to copy this id to other host and I run this command ssh-copy-id -i /.ssh/idrsa.pub userremotehost and the result is /usr/bin/ssh-copy-id: ERROR: No identities found I see and try several tutorial with this error, but I cann't solved.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |