Ssh config file different location


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ssh config file different location
# 1  
Old 02-12-2013
Ssh config file different location

I'm trying use 'sed' to change a line on sshd_config file. But the problem is sshd_config file can be two different locations.(eg: /etc/ssh/sshd_config or /usr/local/ssh/sshd_config)

Was wondering how to write a shell script to search or mention the sshd_config location?
# 2  
Old 02-12-2013
How about running sed only if file exist?
Code:
[[ -f /etc/ssh/sshd_config ]] && sed ... 
[[ -f /usr/local/ssh/sshd_config ]] && sed ...

# 3  
Old 02-12-2013
Yes I can do that, but sometimes sshd_config file is located in both locations.

So I wanna write a script like,

if /etc/ssh/sshd_config exists, then execute sed,
if not then go for /usr/local/ssh/sshd_config and execute sed.

Or is there anyway that we could find the file sshd_config and execute the command?
# 4  
Old 02-12-2013
Quote:
Originally Posted by pjeedu2247
if /etc/ssh/sshd_config exists, then execute sed,
if not then go for /usr/local/ssh/sshd_config and execute sed.
Code:
if [ -f /etc/ssh/sshd_config ]
then
      sed ... /etc/ssh/sshd_config
elif [ -f /usr/local/ssh/sshd_config ]
then
      sed ... /usr/local/ssh/sshd_config
fi

This User Gave Thanks to Yoda For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running Script at a location with SSH

Hi All I have created a script which is running properly "Script". I want that script to run when I login into another server. in the code below: when ssh is executed it asks for password ..After entering password the user is logged in but the script does not run.... whereas when I exit... (1 Reply)
Discussion started by: pulkitbahl
1 Replies

2. Shell Programming and Scripting

How to find a existing file location and directory location in Solaris box?

Hi This is my third past and very impressed with previous post replies Hoping the same for below query How to find a existing file location and directory location in solaris box (1 Reply)
Discussion started by: buzzme
1 Replies

3. Shell Programming and Scripting

File created in a different location instead of desired location on using crontab

Hi, I am logging to a linux server through a user "user1" in /home directory. There is a script in a directory in 'root' for which all permissions are available including the directory. This script when executed creates a file in the directory. When the script is added to crontab, on... (1 Reply)
Discussion started by: archana.n
1 Replies

4. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

5. UNIX and Linux Applications

Central Location for all ssh Keys and Settings Unattended Secure File Transfer

I am developing an application that submits command line file transfers using ssh (Sun to Sun) and Tectia ssh (Sun to Windows Server) embedded in the code. Potentially many different trusted people will start the programs. Is there a way to have all the settings and keys localized so that there is... (0 Replies)
Discussion started by: PowersThatB
0 Replies

6. Shell Programming and Scripting

ssh config file

Hello all I have question regarding the id_dsa keys and authorized_keys file in .ssh directory. I know if we try to SFTP, id_dsa.pub file on server1 will be verified with contents of authorized_keys on other server and SFTP will happen once verification passes. No i want to use id_dsa1.pub... (1 Reply)
Discussion started by: vasuarjula
1 Replies

7. Solaris

ssh service location on Solaris 8

Hi where can i find the ssh service on solaris 8 if "sshd" it is not available on /etc/init.d? i want to restart the service. i did a "which" and i found this. is this the right path? i want to double check since this is a prod server. bash-2.03# which sshd /usr/sbin/sshd Thanks (4 Replies)
Discussion started by: hrist
4 Replies

8. Shell Programming and Scripting

parsing config file to create new config files

Hi, I want to use a config file as the base file and parse over the values of country and city parameters in the config file and generate separate config files as explained below. I will be using the config file as mentioned below: (config.txt) country:a,b city:1,2 type:b1... (1 Reply)
Discussion started by: clazzic
1 Replies

9. Shell Programming and Scripting

Put one string from one location to another location in a file

Hi Everyone, I have 1.txt here a b c' funny"yes"; d e The finally output is: here a b c d e' funny"yes"; (1 Reply)
Discussion started by: jimmy_y
1 Replies

10. UNIX for Advanced & Expert Users

SSH and config.....

Hi all! I'm new to the SSh concept, and i'm supposed to install SSH over 400 servers. I found out how to generate all the keys and the passphrases ( you'll say that ain't that hard!). But now, i just can't get the thing to start. I started sshd on both of my test servers, and on one of 'em, i... (1 Reply)
Discussion started by: penguin-friend
1 Replies
Login or Register to Ask a Question