Sponsored Content
Full Discussion: Automating ssh connection
Top Forums Shell Programming and Scripting Automating ssh connection Post 303005294 by developy on Monday 16th of October 2017 09:46:01 PM
Old 10-16-2017
Code:
#!/bin/bash

if [ "$1" == "" ]
then
clear
echo "how to use:"
echo "i 111.222.333.444"
echo "i name"
echo "i name.exemple.com.fr"
echo ""
fi

#verifying that the input is a valid ip
if [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
      clear
      echo "Success! Accessing $1 with devops"
      ssh devops@$1
 elif
      clear
      echo "Oops! Could not access with devops, trying to access as matheus"
      ssh -i /home/devops/.ssh/matheus_rsa matheus@$1
else
      clear
      echo "Could not connect! Here's some information to access the provider platform."
      whois $1 | grep -E "mnt-by|OrgName|nserver"
      getent hosts $1
fi

#-f If you have text
if [ -f $1 ]; then
      clear
      echo "Success! Accessing $1 with devops"
      ssh devops@$1.exemple.com.fr
  elif
      clear
      echo "[1] Trying to connect..."
      ssh devops@$1
  elif
      clear
      echo "Oops! Could not access with devops, trying to access as matheus"
      ssh -i /home/devops/.ssh/matheus_rsa matheus@$1.exemple.com.fr
  elif
      clear
      echo "[2] Trying to connect..."
      ssh -i /home/devops/.ssh/matheus_rsa matheus@$1
else
      echo "Could not connect! Here's some information to access the provider platform."
      whois $1 | grep -E "mnt-by|OrgName|nserver"
      getent hosts $1
fi

 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

ssh connection

pls how do i connect to my freebsd server via ssh from a windows client?? I have sshd running on d freebsd server. (9 Replies)
Discussion started by: lealyz
9 Replies

2. UNIX for Dummies Questions & Answers

ssh connection

Hi @ all! I've a problem with a ssh-connection. I want to establish a ssh-connection between an AIX-System and an SunOS-System without a password. The Users are different one's. Command : user1@server1 /home/user1 > ssh user2@server2 Is it possible? Greetings olli-h (1 Reply)
Discussion started by: olli-h
1 Replies

3. Shell Programming and Scripting

automating ssh session with password

Hi Can anyone help me in automate a ssh session with password using shell script (7 Replies)
Discussion started by: raghav288
7 Replies

4. Shell Programming and Scripting

Automating file transfer between two SSH enabled server.

Hi Experts, Few more words to the title, both the servers are ssh enabled but I have read only access to the second server, so I cannot automate SFTP process using RSA/DSA keys. I am using Control M to trigger the script and do not want any manual intervention to enter the password to complete... (4 Replies)
Discussion started by: nchourasiya
4 Replies

5. Red Hat

Ssh connection

hi, I have ssh connection between two servers for a functional Id for SFTP purpose. I aim is to setup this for is only work when below command is used by a .ksh script. ssh userid@servername:/directory Unfortunately users who have access to functional id are manually using above command... (2 Replies)
Discussion started by: maddy26615
2 Replies

6. UNIX for Advanced & Expert Users

How keep running a program n an another computer via a connection ssh when the connection is closed?

Hi everybody, I am running a program on a supercomputer via my personal computer through a ssh connection. My program take more than a day to run, so when I left work with my PC I stop the connection with the supercomputer and the program stop. I am wondering if someone know how I can manage... (2 Replies)
Discussion started by: TomTomGre
2 Replies

7. UNIX for Advanced & Expert Users

Connection-less using ssh

Hi! I know its a recurring problem, but I am failing to sort this out, I have two servers ( A and B), in which I am able to connect without having to put password from server B to server A, but the connect from server A to server B. takes 7 minutes to establish??? on Server A, I have the... (7 Replies)
Discussion started by: fretagi
7 Replies

8. BSD

Connection SSH to remote by ssh

Hello guys! I am setting up a script to access a unix remote server. My problem is that when I put the ssh line "my host", the script does not wait for the server response asking for the password to execute the line in which I put the password, that is, I need to put a form in which script has a... (1 Reply)
Discussion started by: aroucasp
1 Replies

9. UNIX for Beginners Questions & Answers

Ssh script to validate ssh connection to multiple serves with status

Hi, I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not... I have .sh script like below and i have servers.txt contains all the list of servers #/bin/bash for host in $(cat... (3 Replies)
Discussion started by: sreeram4
3 Replies
SSH-ARGV0(1)						    BSD General Commands Manual 					      SSH-ARGV0(1)

NAME
ssh-argv0 -- replaces the old ssh command-name as hostname handling SYNOPSIS
hostname | user@hostname [-l login_name] [command] hostname | user@hostname [-afgknqstvxACNTX1246] [-b bind_address] [-c cipher_spec] [-e escape_char] [-i identity_file] [-l login_name] [-m mac_spec] [-o option] [-p port] [-F configfile] [-L port:host:hostport] [-R port:host:hostport] [-D port] [command] DESCRIPTION
ssh-argv0 replaces the old ssh command-name as hostname handling. If you link to this script with a hostname then executing the link is equivalent to having executed ssh with that hostname as an argument. All other arguments are passed to ssh and will be processed normally. OPTIONS
See ssh(1). FILES
See ssh(1). AUTHORS
OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0. Jonathan Amery wrote this ssh-argv0 script and the associated documentation. SEE ALSO
ssh(1) Debian Project September 7, 2001 Debian Project
All times are GMT -4. The time now is 01:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy