Re: kmail through ssh tunnel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 08 October 2020 01:55:36 am Dr. Nikolaus Klepp wrote:
> Anno domini 2020 Wed, 7 Oct 23:34:34 -0700
>
>  William Morder via tde-users scripsit:
> > On Wednesday 07 October 2020 23:07:55 Dr. Nikolaus Klepp wrote:
> > > Anno domini 2020 Wed, 7 Oct 16:32:12 -0700
> > >
> > >  William Morder via tde-users scripsit:
> > > > I believe it was Michael who wrote this memorable line, which
> > > > immediately got
> > > >
> > > > my attention:
> > > > > POP through an always present SSH tunnel.
> > > >
> > > > that an ssh tunnel would be the way, but how to do it?

No offense Nik, your somewhereelse anthology left me a bit confused, attached 
is a filtered bash script I use to maintain the SSH tunnel.  In my use case, 
I’m always connected to the server anyway, so adding the tunnel just made 
sense.

My KMail setup is (change whatever you need to for your specific mail setup):

Menu >> Settings >> Configure, Accounts

Receiving, Add, Account Type: POP3

Tab: General

Login: Mail account name
Password: Mail account password
Host: 127.0.0.1
Port: 58110

Yes: Store POP password
{the rest whatever you normally do}

Tab: Extras

Encryption: None
Authentication Method: Clear text
{You can check what the server does, in my case it’s going through the tunnel 
on a box I own, so I leave it simple}
{pipelining:  I’ve never enabled it, the warning is enough for me...}

Sending, Add, Transport: SMTP

Tab: General

Host: 127.0.0.1
Port: 58025

Yes: Server requires authentication
Login: Mail account name
Password: Mail account password
Yes: Store SMTP password

Tab: Security
Encryption: TLS
Authentication Method: LOGIN

# # #

Hopefully that helps!

Best,
Michael
#!/bin/bash
# # # Description
# SSH to a server
#  - Add a tunnel for mail
#  - Reconnect when pipe breaks
#  - Be pretty
#
# Notes:
#  - You must have setup key authorization
#  - (no password SSH login)
#
####
#  Includes
# . "/home/michael/common/bin/includes/stdpaths.sh"
# . "$CommonInc/pretty.sh"
# # # #

#### Variable explained
# These variables are pulled in through includes
#
# MbVarNetIface='wlan0'  # Which interface you connect through
# "pretty.sh" pasted as comments at the bottom

#### Let's Begin
# . "$sftpmeInc/filename" # I keep all my server credentials in one spot, hardcode like below otherwise
# PORT="1009"  # Use if you mail server uses a non-standard SSH port
# PORT=""
# IP="999.999.999.999" # IP of mail server
# DOMAIN="SRVNN-inet-design.com"  # Display only, useful if you have a ton of SSH's open
# ACCOUNT="" # SSH account name on mail server
D00=`date`
MESG="Start"
SSHFlagDied=0

echo
echo -e "             ## "$RED_F$BOLD$MESG$NORM" ##           " $D00

while [ 1 ] ; do
# TEST01 changes on based upon version of ifconfig, I return an IP address for my tests.
# TEST02 I hardcode to eth0 for portability and fallback.
  TEST01=`ifconfig $MbVarNetIface 2>/dev/null |grep "inet "|cut -d" " -f10`
  TEST02=`ifconfig eth0 2>/dev/null |grep "inet "|cut -d" " -f10`
# Older ifconfig usage:
#   TEST01=`ifconfig $MbVarNetIface 2>/dev/null |grep "inet addr"|cut -d":" -f2|cut -d" " -f1`
#   TEST02=`ifconfig eth0 2>/dev/null |grep "inet addr"|cut -d":" -f2|cut -d" " -f1`

  if [ $TEST01 ] || [ $TEST02 ]; then
    D00=`date +"%y-%m-%d %H:%M:%S"`
    MESG="Starting SSH to $DOMAIN ($IP)"
    echo -e $YELLOW_F$D00$NORM" "$GREEN_F"Start"$NORM", "$CYAN_F$MESG$NORM

    SSHTimeStart=`date +%s`
    if [ "$PORT" = "" ] ; then
      ssh -L 58025:$IP:25 -L 58110:$IP:110 "$ACCOUNT@$IP"
    else
      ssh "-p $PORT" -L 58025:$IP:25 -L 58110:$IP:110 "$ACCOUNT@$IP"
    fi
    SSHTimeStop=`date +%s`
    SSHTimeElapsed=`expr $SSHTimeStop - $SSHTimeStart`
    tput cuu 1

    if   [ $SSHTimeElapsed -lt 300 ] && [ $SSHFlagDied = 1 ] ; then
      tput cuu 1
    else
      SSHFlagDied=1
      D00=`date +"%y-%m-%d %H:%M:%S"`
      MESG="Connection Died "
      echo -e $YELLOW_F$D00$NORM" "$RED_F"Died"$NORM" , "$CYAN_F$MESG$NORM
    fi
  fi

  sleep 90s # take a nap, check it again

done


# # cat "$CommonInc/pretty.sh"
# #!/bin/bash
# #
# 
# ####
# #   Prettify things:
# INVT="\033[7m"
# NORM="\033[0m"
# BOLD="\033[1m"
# BLINK="\033[5m"
# 
# #### Old list
# BLACK_F="\033[30m"
# BLACK_B="\033[40m"
# RED_F="\033[31m"
# RED_B="\033[41m"
# GREEN_F="\033[32m"
# GREEN_B="\033[42m"
# YELLOW_F="\033[33m"
# YELLOW_B="\033[43m"
# BLUE_F="\033[34m"
# BLUE_B="\033[44m"
# MAGENTA_F="\033[35m"
# MAGENTA_B="\033[45m"
# CYAN_F="\033[36m"
# CYAN_B="\033[46m"
# WHITE_F="\033[37m"
# WHITE_B="\033[47m"
# ####
# 
# #### New list
# F_BLACK_F="\033[30m"
# B_BLACK_B="\033[40m"
# F_RED_F="\033[31m"
# B_RED_B="\033[41m"
# F_GREEN_F="\033[32m"
# B_GREEN_B="\033[42m"
# F_YELLOW_F="\033[33m"
# B_YELLOW_B="\033[43m"
# F_BLUE_F="\033[34m"
# B_BLUE_B="\033[44m"
# F_MAGENTA_F="\033[35m"
# B_MAGENTA_B="\033[45m"
# F_CYAN_F="\033[36m"
# B_CYAN_B="\033[46m"
# F_WHITE_F="\033[37m"
# B_WHITE_B="\033[47m"
____________________________________________________
tde-users mailing list -- users@xxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxx
Web mail archive available at https://mail.trinitydesktop.org/mailman3/hyperkitty/list/users@xxxxxxxxxxxxxxxxxx

[Index of Archives]     [Trinity Devel]     [KDE]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]     [Trinity Desktop Environment]

  Powered by Linux