diff --git a/Day-02/01-passwordless-authentication.md b/Day-02/01-passwordless-authentication.md index 0d1946f..7701380 100644 --- a/Day-02/01-passwordless-authentication.md +++ b/Day-02/01-passwordless-authentication.md @@ -19,3 +19,50 @@ ssh-copy-id -f "-o IdentityFile " ubuntu@ - Update `PasswordAuthentication yes` - Restart SSH -> `sudo systemctl restart ssh` + + + +how to create the sshd. +The error "zsh: no matches found: /Users/akhilreddyannapureddy/.ssh/id_*" suggests that there are no files matching the pattern `/Users/akhilreddyannapureddy/.ssh/id_*` in your `.ssh` directory. This likely means you do not have any SSH keys generated yet. + +Let's generate a new SSH key pair and then copy it to your remote server: + +### 1. Generate a New SSH Key Pair +Run the following command to generate a new SSH key pair. You can use RSA or Ed25519. Here is an example using RSA: +```sh +ssh-keygen -t rsa -b 4096 -C "your_email@example.com" +``` +Replace `"your_email@example.com"` with your email address. This command will prompt you for a file location to save the key (default is `~/.ssh/id_rsa`) and an optional passphrase. + +### 2. Add the SSH Key to the SSH Agent +After generating the key, add it to the SSH agent: +```sh +eval "$(ssh-agent -s)" +ssh-add ~/.ssh/id_rsa +``` +If you used a different name or location for your key, adjust the path accordingly. + +### 3. Copy the SSH Key to the Remote Server +Use `ssh-copy-id` to copy your SSH key to the remote server: +```sh +ssh-copy-id user@remote_host +``` +Replace `user` with your remote username and `remote_host` with the remote server's address. + +### 4. Verify the SSH Connection +Finally, test the SSH connection to ensure key-based authentication works: +```sh +ssh user@remote_host +``` + +### Additional Notes +- Ensure the `.ssh` directory and the key files have the correct permissions. For example: + ```sh + chmod 700 ~/.ssh + chmod 600 ~/.ssh/id_rsa + chmod 644 ~/.ssh/id_rsa.pub + ``` +- If you encounter any issues, make sure your SSH configuration in `~/.ssh/config` (if it exists) is correct and that the remote server is configured to accept key-based authentication. + +By following these steps, you should be able to generate a new SSH key pair, add it to the SSH agent, and copy it to your remote server, resolving the initial issue. + diff --git a/Day-03/01-yaml-basics.md b/Day-03/01-yaml-basics.md index 4530512..4da0e1f 100644 --- a/Day-03/01-yaml-basics.md +++ b/Day-03/01-yaml-basics.md @@ -47,3 +47,30 @@ family: - name: Jenny age: 20 ``` + + + +### playbook to create the directory and the files in the host system. +``` +--- +- name: Create directory and file + hosts: all + become: true + tasks: + - name: Create directory named foo + file: + path: /path/to/foo + state: directory + mode: '0755' + owner: root + group: root + + - name: Create file named akhil inside foo directory + file: + path: /path/to/foo/akhil + state: touch + mode: '0644' + owner: root + group: root +ansible-playbook -i inventory.ini second-playbook.yaml +``` diff --git a/Day-04/01-roles.md b/Day-04/01-roles.md index 042f827..87108c9 100644 --- a/Day-04/01-roles.md +++ b/Day-04/01-roles.md @@ -85,4 +85,9 @@ of the infrastructure independently. ### Consistency Using roles ensures that the same setup and configuration procedures are applied uniformly across -multiple environments, reducing the risk of configuration drift. \ No newline at end of file +multiple environments, reducing the risk of configuration drift. + + + +### to create the role in the ansible we need to use the below command. +ansible-galaxy role init test1